Skip to content

frfernandezdev/bff-poke-vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poke Vault 🚀✨

This project is a Backend For Frontend (BFF) designed to act as an intermediary between the public PokeApi and the frontend applications consuming the data. The BFF is designed to simplify requests to PokeApi, optimize responses, and provide an additional layer of business logic.

nodejs node typescript npm fastify swc swc docker

DEMO PokeVault

Technologies Used

  • Node.js: JavaScript runtime environment for backend.
  • NestJS: Modular framework for building scalable and maintainable applications.
  • RxJS: Library for reactive programming and handling asynchronous streams.
  • TypeScript: Adds static typing to enhance code safety and maintainability.

Prerequisites

Before starting this epic adventure, make sure you have these technological superpowers at hand:

  • Node.js 🌐: For all your JavaScript runtime needs.
  • Docker 🐳: The container of your dreams.
  • Git 🧑‍💻: To keep everything under control with style.

Developing

First, we will need to create our .env file, we can create a copy from the example one:

cp .env.example .env

The project is fully dockerized 🐳, if we want to start the app in development mode, we just need to run:

docker-compose up -d dev

This development mode will work with hot-reload and expose a debug port, port 9229, so later we can connect to it from our editor.

Now, you should be able to start debugging configuring using your IDE. For example, if you are using vscode, you can create a .vscode/launch.json file with the following configuration:

{
  "version": "0.1.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to docker",
      "restart": true,
      "port": 9229,
      "remoteRoot": "/app"
    }
  ]
}

Also, if you want to run the production mode, you can run:

docker-compose up -d production

This service is providing just a health endpoint which you can call to verify the service is working as expected:

curl --request GET \
  --url http://localhost:3000/health

If you want to stop developing, you can stop the service running:

docker-compose down

Usage

To visit this http://localhost

This BFF exposes the following endpoints:

  • GET /pokemons/: Retrieves a list of all Pokémon.
  • GET /pokemons/: Retrieves detailed information about a specific Pokémon by its ID.
  • GET /pokemonAndTypes/: Fetches data about a Pokémon and its types.

Additionally, you can access the API documentation generated by Swagger at http://localhost:3000/api/docs.

Building

npm run build

Testing

The service provide different scripts for running the tests, to run all of them you can run:

npm run test

If you are interested just in the unit tests, you can run:

npm run test:unit

Or if you want e2e tests, you can execute:

npm run test:e2e

We also have performance testing with k6, if you want to run it via docker, execute:

docker-compose up k6

Or if you want to run it from your machine, execute:

brew install k6
npm run test:performance

Linting

To run the linter you can execute:

npm run lint

And for trying to fix lint issues automatically, you can run:

npm run lint:fix

Deploy to Production

This project is automatically deployed to production using Koyeb. Every time a change is pushed to the main branch, Koyeb will build and deploy the latest version of the BFF to production. You can access the deployed application via the Koyeb-generated URL.

About

Background For Fronted Poke Vault

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published