Minimal Boilerplate for Node.js API Server with Mongodb
- Node Server with
express.js
- API Example with Router-Controller-Model Structure
- Mongodb CRUD with
mongoose
- Swagger API Documentation
- Test
- Dockerfile
Create .env
on project root.
SERVER_IP=0.0.0.0
SERVER_PORT=3000
MONGODB_USERNAME=admin
MONGODB_PASSWORD=admin
$ sudo apt-get install npm nodejs mongodb
$ npm install
$ npm start
First, Install docker & docker-compose
$ docker-compose up
$ npm run test
localhost:3000/swagger
├── src/
│ ├── index.js 1. receive request
│ ├── routes/ 2. route request by url
│ ├── middlewares/ 3. authenticate or check something
│ ├── controllers/ 4. do some business logic
│ ├── models/ 5. query database
│ ├── utils/ - utilities
├── tests/ - api test codes
└── config.js - server configurations
- Framework: express
- Database: mongoose
- Documentation: swagger-jsdoc, swagger-ui-express
- Test: mocha, chai
- Logger: morgan