Skip to content

RESTful API for products using JavaScript, Node.js, Express.js, MongoDB, Docker, RabbitMQ, Swagger, and GitHub Actions.

License

Notifications You must be signed in to change notification settings

sidneyrmedeiros/node-express-crud

Repository files navigation

NodeJS Express MongoDb

Build Status License MIT

Product CRUD

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

Stack

The following stack was used:

  • NodeJS
  • Express
  • MongoDB
  • Docker
  • RabbitMQ (incomplete)

Installation

  1. Clone/Download the repo: git clone https://github.com/sidneyrmedeiros/node-express-crud.git
  2. Copy the .env.example file to .env and configure your environment variables.
  3. To build the containers, run docker-compose up --build.
  4. 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

Once everything is installed, you are ready to go.

Usage

  1. To run, use docker-compose up.
  2. Access the Swagger Documentation: http://localhost:3000/swagger
  3. To authenticate: http://localhost:3000/swagger/#/Auth/post_api_auth
{
  "username": "admin",
  "password": "123456"
}
  1. Access the Products API: http://localhost:3000/api/products
  2. Access the Joke API: http://localhost:3000/api/joke
{
  "value": "Greek Gods fled to Mount Olympus they saw Chuck Norris wandered on earth."
}
  1. Access the local RabbitMQ: http://localhost:15673/

Once everything is installed, you are ready to go.

Test

  1. Run tests by docker exec crud-node-api npm test
by Sidney Ricardo Medeiros

Follow Me

LinkedIn Sidney Ricardo Medeiros

About

RESTful API for products using JavaScript, Node.js, Express.js, MongoDB, Docker, RabbitMQ, Swagger, and GitHub Actions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published