A RESTful API developed in Javascript to demonstrate the use of the tech stack. An authentication mechanism using JWT Token has been implemented, with a mock admin user. A local RabbitMQ via Docker was implemented to receive data after requests, although it has not been finalized.
This CRUD includes the following routes:
- GET /api/products
- POST /api/products
- GET /api/products/{id}
- PUT /api/products/{id}
- DELETE /api/products/{id}
- POST /api/auth
- GET /api/joke
- GET /api/health
The following stack was used:
- NodeJS
- Express
- MongoDB
- Docker
- RabbitMQ (incomplete)
- Clone/Download the repo:
git clone https://github.com/sidneyrmedeiros/node-express-crud.git
- Copy the
.env.example
file to.env
and configure your environment variables. - To build the containers, run
docker-compose up --build
. - Configure the MongoDB URL in the
.env
file:- Local:
MONGODB_URL=mongodb://mongo:27017/docker-node-mongo
- Atlas MongoDB:
MONGODB_URL=mongodb+srv://user:pass@{database}.mongodb.net/?retryWrites=true&w=majority
- Local:
Once everything is installed, you are ready to go.
- To run, use
docker-compose up
. - Access the Swagger Documentation: http://localhost:3000/swagger
- To authenticate: http://localhost:3000/swagger/#/Auth/post_api_auth
{
"username": "admin",
"password": "123456"
}
- Access the Products API: http://localhost:3000/api/products
- Access the Joke API: http://localhost:3000/api/joke
{
"value": "Greek Gods fled to Mount Olympus they saw Chuck Norris wandered on earth."
}
- Access the local RabbitMQ: http://localhost:15673/
Once everything is installed, you are ready to go.
- Run tests by
docker exec crud-node-api npm test