This repository contains an API to play with Pokemons. It has been builded with:
- NodeJS 💻
- Express ⚡
- Mongo 💿
- Mongoose 🐁
- Docker 🐳
You can run this API through:
- Node and NPM and Mongo installed on your host.
- Docker and Docker Compose
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
- Open your Docker Desktop
cd <project_path>/pokeapi
docker-compose up -d
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
cd <project_path>/pokeapi
npm install
npm run seed
npm run dev
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.
-
touch .vscode/launch.json
-
{ "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" } ] }
-
If you have ran with Docker just play the debugger
-
If you are on localhost you have to run api with
npm run debug
Have fun 🎉