Skip to content

Latest commit

 

History

History
77 lines (56 loc) · 1.77 KB

README.md

File metadata and controls

77 lines (56 loc) · 1.77 KB

nodejs-api-server-boilerplate

Minimal Boilerplate for Node.js API Server with Mongodb

License: MIT

Included

  • Node Server with express.js
  • API Example with Router-Controller-Model Structure
  • Mongodb CRUD with mongoose
  • Swagger API Documentation
  • Test
  • Dockerfile

Usage

Config

Create .env on project root.

SERVER_IP=0.0.0.0
SERVER_PORT=3000
MONGODB_USERNAME=admin
MONGODB_PASSWORD=admin

Run

$ sudo apt-get install npm nodejs mongodb
$ npm install
$ npm start

Run with Docker

First, Install docker & docker-compose

$ docker-compose up

Test

$ npm run test

Swagger Documentation

localhost:3000/swagger

File Tree

├── 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

Packages