- Uses yarn
- No transpilers, just vanilla javascript with ES2017 latest features like Async/Await
- Express + MongoDB (Mongoose)
- CORS enabled and uses helmet to set some HTTP headers for security
- Load environment variables from .env files with dotenv
- Request validation with joi
- Consistent coding styles with editorconfig
- 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
- Rate limiting with express-rate-limit
- API documentation generation with apidoc
- Docker support
- Continuous integration support with travisCI
- Monitoring with pm2
Take a demo at http://13.58.200.57:3000/docs/
- Node v7.6+ or Docker
- Yarn
- Clone the repo and make it yours:
git clone https://github.com/ridhamtarpara/express-es8-rest-boilerplate node-api
cd node-api
rm -rf .git
- Install dependencies:
yarn
- Set environment variables:
cp .env.example .env
yarn dev
yarn start
# lint code with ESLint
yarn lint
# try to fix ESLint errors
yarn lint:fix
# lint and watch for changes
yarn lint:watch
# 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
# run lint and tests
yarn validate
# show logs in production
pm2 logs
# generate and open api documentation
yarn docs
# run container locally
yarn docker:dev
or
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
# run container in production
yarn docker:prod
or
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
# run tests
yarn docker:test
or
docker-compose -f docker-compose.yml -f docker-compose.test.yml up
Set your server ip:
DEPLOY_SERVER=127.0.0.1
Replace my Docker username with yours:
nano deploy.sh
Run deploy script:
yarn deploy
or
sh ./deploy.sh
Change configuration in .env
file