V9nineIX / nft-toolkit-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About


Languages

Language:JavaScript 99.6%Language:Dockerfile 0.4%