/pokeapi

Pokemon API Rest builded with NodeJS + Express + Mongoose + MongoDB + Docker + GraphQL

Primary LanguageJavaScript

POKEMON API

This repository contains an API to play with Pokemons. It has been builded with:

  • NodeJS 💻
  • Express ⚡
  • Mongo 💿
  • Mongoose 🐁
  • Docker 🐳

Environment

You can run this API through:

You have to create two files in config folder

  • .env
  • .env.development
touch <project_path>/pokeapi/config/.env

If you run the API with Docker

echo "MONGODB_URI=mongodb://admin:password@mongo:27017" > <project_path>/pokeapi/config/.env.development

If you run the API with Node and Mongo with your localhost

echo "MONGODB_URI=mongodb://admin:password@localhost:27017" > <project_path>/pokeapi/config/.env.development

Run with Docker

  1. Open your Docker Desktop
  2. cd <project_path>/pokeapi
  3. docker-compose up -d
  4. docker-compose exec node npm run seed

At this point you should have the API and Database running as a Docker containers.

And also the database seeded with 809 Pokemons!

## Run without Docker

  1. cd <project_path>/pokeapi
  2. npm install
  3. npm run seed
  4. npm run dev

Postman

In the project you have Postman folder that contains:

  • [DEV]PokeAPI.postman_environment.json
  • PokeAPI.postman_collection.json

Import these files in Postman, and select the environment, then execute any request.

## Debug If you want to debug with Docker you have to create a file and the copy the following JSON object.

  1. touch .vscode/launch.json

  2.  {
         "version": "0.2.0",
         "configurations": [
             {
                 "name": "Docker: Attach to Node",
                 "type": "node",
                 "request": "attach",
                 "restart": true,
                 "port": 9229,
                 "address": "localhost",
                 "localRoot": "${workspaceFolder}",
                 "remoteRoot": "/usr/src/app",
                 "protocol": "inspector"
             }
         ]
     }
  3. If you have ran with Docker just play the debugger

  4. If you are on localhost you have to run api with npm run debug

Have fun 🎉