This project is an example of REST API written in Node 22+ that makes use of Koa framework, Awilix container and MongoDB.
It basically has two endpoints that allow us to perform some CRUD operations:
- /v1/state
- /v1/city
The endpoints are protected by a basic authorization header in the following format Authorization: Basic .....
You can use the following value for testing purposes only Basic NDAxNTU3Y2YtY2Q1OS00MTBlLTlkNTUtOGJhNzk2OTU1ZjVjOmI3ZmZlYjVmZjBhMTQ0NTNmZTcyNWY4Mjc3NTMyODk3ZTQ0MzdhMTQ=. It is not recommended to have credentials exposed in your code!
Note: By default, the rate limit is 100 requests per second.
The endpoint's documentation is located in /docs folder. It was written on top of OpenAPI v3 notation.
OBS: Node.JS and MongoDB are required
- Run
npm install - Run
npm run dev - Optionally run
NODE_ENV=development node command.js populate:db --dropto seed the database. - Make calls to the endpoints via Postman or similar in the following address
0.0.0.0:3000/v1/state
Using it with Docker
docker compose up -d- Optionally run
docker exec -it geonames-node bash -c 'node command.js populate:db --drop'to seed the database. - Make calls to the endpoints via Postman or similar in the following address
0.0.0.0:8080/v1/state
- Run
npm run test
- You can check the api running on
Herokuby clicking here. - You can check the simple Vue.js app running on
Herokuby clicking here.
Drop me an e-mail
- Fetch credentials from database (cached) in order to keep it more easily to maintain
- Create more unit tests to have a 100% coverage score.