Get the application DB up first, using Postgres Docker Image
docker pull postgres
docker run --name postgres-db -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres
Then execute the following command start the application in dev mode
npm run start:dev
Check the health of the application from the url http://localhost:3000/health
In order to access the private the routes, we need to pass the JWT token generated by the login API
- Authentication using JWT
- Password Encryption using bcrypt
- Unit testing using jest
- Swagger to interact with the APIs
- Used PostgreSQL and Sequelize
- Deployment Using Docker and Docker Compose
- Execute the unit test cases using the command
npm test
Access the Swagger from the URL http://localhost:3000/api-docs/
In order to communicate between containers we need to create a user-defined custom bridge networks
docker network create -o com.docker.network.bridge.enable_icc=true custom-network
Then, Get the Postgres DB up. Run the postgres image, passing the newly created network custom-network
docker run --network custom-network --name postgres-db -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
Then, build the app's image
docker build . -t kingshuknandy/node-microservice
Finally, run the app's image, passing the newly created network custom-network
docker run -p 3000:3000 --network custom-network --env-file .env --env DB_HOST='postgres-db' --name node-microservice kingshuknandy/node-microservice:latest
- Created the Dockerfile to build the app
- Defined the services that make up the app in docker-compose.yml so they can be run together in an isolated environment.
- Run docker-compose up and Compose starts and runs your entire app.
docker-compose up
# Public API Routes:
+--------+------------------------------+
Method | URI
+--------+------------------------------+
GET | /health
POST | /apis/v1/auth/signUp
POST | /apis/v1/auth/login
GET | /apis/v1/employees/getEmployeeBasic
GET | /apis/v1/employees/getEmployees
POST | /apis/v1/employees/setEmployee
+--------+------------------------------+
# Private API Routes:
+--------+------------------------------+
Method | URI
+--------+------------------------------+
GET | /apis/v1/users/getUsersBasic
GET | /apis/v1/users/getUsers
POST | /apis/v1/users/setUser
+--------+------------------------------+