book management api, using express and mongodb
Deployed on Digital Ocean Server: https://book-management.meanii.dev/books
Demo Video: https://www.youtube.com/watch?v=IKx0A9xu6TE
There are two ways to run this project
- legacy way
- using docker compose (recommended)
You need to have nodejs and mongodb installed on your machine
- Clone this repository
git clone https://github.com/meanii/book-management
- Install dependencies
npm install
- Run server
npm start
You need to have docker and docker-compose installed on your machine
- Install docker and docker-compose
curl -o- https://get.docker.com | sh -x
- Clone this repository
git clone https://github.com/meanii/book-management
- Run docker-compose
docker compose up
default limit is 10, you can change it by adding limit
query parameter
GET /books
GET /books?limit=20&page=2
GET /books/:id
POST /books
{
"title": "string",
"author": "string",
"summary": "string"
}
PUT /books/:id
{
"title": "string",
"author": "string",
"summary": "string"
}
DELETE /books/:id
pre-requisite:
- VPS Server (Digital Ocean, AWS, etc)
- OS: Ubuntu 20.04 LTS (recommended)
- Domain Name (optional)
- Docker and Docker Compose installed on your server
- Git installed on your server
- Nginx installed on your server
- SSL Certificate (optional)
You need to have docker and docker-compose installed on your server
- Install docker and docker-compose
curl -o- https://get.docker.com | sh -x
- Clone this repository
git clone https://github.com/meanii/book-management && cd book-management
- Run docker-compose
docker compose up -d
useful docker and docker compose commands:
docker ps # show running containers
docker ps -a # show all containers
docker compose ps # show running containers using docker compose
docker compose logs --follow --tail 100 # show logs of all containers using docker compose
docker logs <container-id> # show logs of a container
docker exec -it <container-id> bash # enter a container
- Install Nginx
sudo apt update
sudo apt install nginx
- Configure Nginx use nginx.conf as a template
sudo vim /etc/nginx/sites-available/book-management.conf
- Enable Nginx config
sudo ln -s /etc/nginx/sites-available/book-management.conf /etc/nginx/sites-enabled/
- Restart Nginx
sudo systemctl restart nginx
- Install SSL Certificate (optional)
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com