You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
krish f5a5955656 eslint and prettier added 10 months ago
src eslint and prettier added 10 months ago
.env updated code 3 years ago
.env.development package and env update 10 months ago
.env.example updated code 3 years ago
.env.production package and env update 10 months ago
.eslintrc.js eslint and prettier added 10 months ago
.gitignore updated code 3 years ago
.prettierrc eslint and prettier added 10 months ago
Dockerfile initial commit 3 years ago
README.md eslint and prettier added 10 months ago
deploy.sh initial commit 3 years ago
docker-compose.dev.yml eslint and prettier added 10 months ago
docker-compose.prod.yml eslint and prettier added 10 months ago
docker-compose.test.yml eslint and prettier added 10 months ago
docker-compose.yml eslint and prettier added 10 months ago
package-lock.json eslint and prettier added 10 months ago
package.json eslint and prettier added 10 months ago
yarn.lock eslint and prettier added 10 months ago

README.md

Important Information

This repository is exclusively meant for presenting samples of code.

The Files and Codes present in this repository are part of a running project. In order to ensure the security of the project several files have been intentionally removed. The codes are exclusively for viewing purpose and will not execute properly if tried.

Express ES2017 REST API Boilerplate

Boilerplate/Generator/Starter Project for building RESTful APIs and microservices using Node.js, Express and MongoDB

Features

  • No transpilers, just vanilla javascript
  • ES2017 latest features like Async/Await
  • CORS enabled
  • Uses yarn
  • Express + MongoDB (Mongoose)
  • Consistent coding styles with editorconfig
  • Docker support
  • Uses helmet to set some HTTP headers for security
  • Load environment variables from .env files with dotenv
  • Request validation with joi
  • Gzip compression with compression
  • Linting with eslint
  • Tests with mocha, chai and sinon
  • Code coverage with istanbul and coveralls
  • Git hooks with husky
  • Logging with morgan
  • Authentication and Authorization with passport
  • API documentation generation with apidoc
  • Continuous integration support with travisCI
  • Monitoring with pm2

Requirements

Getting Started

Clone the repo and make it yours:

git clone --depth 1 https://git.sentientgeeks.us/krish/sg-node-express-rest-api.git
cd sg-node-express-rest-api
rm -rf .git

Install dependencies:

yarn

Set environment variables:

cp .env.example .env

Running Locally

yarn dev

Running in Production

yarn start

Lint

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

# lint and watch for changes
yarn lint:watch

Test

# run all tests with Mocha
yarn test

# run unit tests
yarn test:unit

# run integration tests
yarn test:integration

# run all tests and watch for changes
yarn test:watch

# open nyc test coverage reports
yarn coverage

Validate

# run lint and tests
yarn validate

Logs

# show logs in production
pm2 logs

Documentation

# generate and open api documentation
yarn docs

Docker

# run container locally
yarn docker:dev

# run container in production
yarn docker:prod

# run tests
yarn docker:test

Deploy

Set your server ip:

DEPLOY_SERVER=127.0.0.1

Replace my Docker username with yours:

nano deploy.sh

Run deploy script:

yarn deploy