Node.js implementation of a REST API using express, mongoose and ES6. It uses JWT authentication and brute-force protection by rate limiting income requests. Also helps your team to promote best practices by following simple conventions.
- ES6 via Babel Babel.
- Authentication via JsonWebToken jsonwebtoken.
- Code Linting ESLint. eslint-config-airbnb.
- Auto server restart nodemon.
- ES6 Code Coverage via istanbul.
- Debugging via debug.
- Promisified Code via bluebird, supertest-as-promised.
- API parameter validation via express-validation.
- Secure app via helmet.
- Brute-force protection by rate limiting requests express-brute.
- Uses yarn over npm.
- CORS support via cors.
- Uses http-status to set http status code.
- Has
.editorconfig
which helps developers define and maintain consistent coding styles between different editors and IDEs.
Clone the repo:
git clone https://github.com/rectius/express-rest-api.git
cd express-rest-api
Install tools:
npm install -g istanbul coveralls commitizen
Install yarn:
npm install -g yarn
Install dependencies:
yarn
Run server:
# Start server
yarn start
# Selectively set DEBUG env var to get logs
DEBUG=express-rest-api:* yarn start
Refer debug to know how to selectively turn on logs.
Tests:
# Run tests written in ES6 along with code coverage
yarn test
# Run tests on file change
yarn test:watch
# Run tests enforcing code coverage (configured via .istanbul.yml)
yarn test:check-coverage
Lint:
# Lint code with ESLint
yarn lint
# Run lint on any file change
yarn lint:watch
Other gulp tasks:
# Wipe out dist and coverage directory
gulp clean
# Default task: Wipes out dist and coverage directory. Compiles using babel.
gulp
# compile to ES5
1. yarn build
# upload dist/ to your server
2. scp -rp dist/ user@dest:/path
# install production dependencies only
3. yarn --production
# Use any process manager to start your services
4. pm2 start dist/index.js
Pablo Souza (Twitter: @pablo_souza)
MIT. Copyright (c) Pablo Souza.