Simple express boilerplate for creating REST API server.
- Authentication with email/password and JWT authentication using passport.js(without blacklisting).
- API rate limiting using express-rate-limit.
- Test integration using Jest and Supertest.
- Logging using morgan.
- Error handling(here).
- ODM using Mongoose.js.
- Precommit code formatting using prettier and testing using husky.
- ES6 support with babel.js.
Variable Name. | description | example |
---|---|---|
JWT_SECRET |
secret for generating JWT | Q>,L+A+6 |
MONGO_DB |
MongoDB connection uri string | mongodb://localhost:27017/Biolerplate |
JWT_TOKEN_EXPIRATION_IN_DAYS |
period after which JWT should expire | 7 |
RATE_LIMIT_WINDOW |
the window in which api calls from a specific IP address can only make a specific amount of request determined in RATE_LIMIT the environment variable. |
60000 (equivalent to one minute) |
RATE_LIMIT |
amount of api calls from a specific IP address that can be made within a given time window determined in the RATE_LIMIT_WINDOW the environment variable. |
100 |
npm i
run from root:
npm run start
run from root:
npm run test
if you want to auto rerun tests on file change run:
npm run test:watch
run from root:
npm run build
npm run serve