A Dockerized Node.js + MongoDB demo app featuring a simple blog rest API.
Note: In order to run this project you must have Docker installed.
To run it, simply execute the docker-compose up
command and docker-compose stop
to stop the application. If you wish to stop and remove the container, you may do so by running docker-compose down
.
Once the app is running, open your browser on http://localhost.
With the docker-compose scale
command, it is very simple to scale your app up or down.
Example:
docker-compose scale api=5 web=2
There are two web servers running, one to serve the web app and its static artifacts and another to serve the express rest API. For that we use Nginx is configured as a reverse proxy and a load balancer. Thus requests to http://localhost are redirected to the web app and requests to http://localhost/api are routed to the api.
- GET /api/{id} - Loads a single blog post by id
- GET /api/{page}/{limit} - Loads paginated blog posts
- DELETE /api/{id} - Deletes a blog post
- PUT /api/{id} - Updates a blog post by id - body schema
- POST /api/{id} - Creates a new blog post - body schema
- GET /api/health - Checks if the api is up and running
- GET /api/populate - Populates the database with test data
The following tools were used on this demo: