/base-nodejs-api-es6

Base NodeJS REST API using ExpressJS, ES6 and Docker

Primary LanguageJavaScriptMIT LicenseMIT

Basic structure for REST API with ExpressJS/NodeJS and Docker integration.

This is a simple and basic structure for deploy API using ExpressJs and NodeJs with docker deploy, easily and quickly.

License: MIT node es6 docker sql mongo ssl helmet

Structure

├── .babelrc
├── docker-compose.yml
├── Dockerfile
├── .dockerignore
├── .eslintrc.js
├── .eslintignore
├── .gitignore
├── LICENSE
├── package.json
├── README.md
└── src
    ├── api
    │   └── example
    │       ├── _index.js
    │       ├── example.js
    │       └── _validates
    │           └── example.validate.js
    ├── app.js
    ├── config
    │   ├── api.conf.js
    │   ├── sequelize.conf.js
    │   └── env
    │       ├── development.env.js
    │       ├── production.env.js
    │       └── test.env.js
    ├── core
    │   ├── Cors.js
    │   ├── Database.js
    │   ├── RequestQuery.js
    │   ├── Response.js
    │   ├── Routers.js
    │   ├── Security.js
    │   └── SSL.js
    ├── schemas
    │   ├── mongodb
    │   │   └── example.js
    │   ├── mysql
    │   │   └── example.js
    │   ├── postgres
    │   │   └── example.js
    │   └── ...
    ├── services
    │   └── example.js
    ├── storage
    │   ├── certificates
    │   │   ├── example.crt
    │   │   └── example.key
    │   ├── logs
    │   └── static
    └── tests
        └── api
            └── example.test.js

Install

# Clone the repo
git clone https://github.com/talesluna/base_nodejs_express_api_es6
cd basic_express_api_structure

# Remove .git
rm -rf .git

# Install packages
npm install
sudo npm install pm2 -g

# Build
npm run build

# Run (local)
npm run dev   # (Development mode)
npm run test  # (Mocha tests)
npm start     # (Production mode with pm2, build before)
npm stop      # (Stop Production)

# Deploy (Docker)
npm run deploy    # (Pull defined image and deploy docker container)
npm run undeploy  # (Stop and remove deployed container)
docker-compose    # (Others deployment options)

# To install docker-compose
sudo apt install python python-pip
sudo pip install docker-compose