This is a flexible, and generic Node.js and Express template which covers most basic to advance needs of modern REST API's. This conveniently implements MongoDB as the database of choice using Mongoose ORM; efficiently reducing the learning curve for using the template.
The template comes with the following dependencies defined:
compression
-https://github.com/expressjs/compression#readme
cors
-https://github.com/expressjs/cors#readme
dotenv
-https://github.com/motdotla/dotenv#readme
helmet
-https://helmetjs.github.io/
mongoDB
-https://www.mongodb.com/
mongoose
-https://mongoosejs.com/
morgan
-https://github.com/expressjs/morgan#readme
winston
-https://github.com/winstonjs/winston#readme
- ESLint
- Prettier
- nodemon
- eslint
- eslint-config-airbnb
- eslint-config-prettier
- eslint-plugin-prettier
- eslint-plugin-security
- jsdoc
- @types/bcrypt
- @types/compression
- @types/cors
- @types/glob
- @types/hpp
- @types/jsonwebtoken
- @types/morgan
- @types/node-cron
- @types/nodemailer
- Install dependencies.
npm i
oryarn install
- Create the following environment variables manually or by copying the
.env.example
file to a.env
file:- To auto generate a .env use:
npm run generate-env
oryarn generate-env
NODE_ENV
: specifies the working environmentAPP_PORT
: Sets a default app port.APP_DB_URI
: Sets a default Mongo DB connection URI.APP_NAME
: Sets the application name.
- To auto generate a .env use:
- Run the Node.js server locally.
npm run dev
oryarn dev
- Test application locally and ensure all tests pass with 100% coverage.
npm run test
oryarn test
- To generate a web based view of the coverage use:
npm run test-publish
oryarn test-publish
- To generate an updated .env.example.
npm run update-example-env
oryarn update-example-env
- To generate documentation using JSDocs.
npm run update-documentation
oryarn update-documentation
- Run in a production environment
npm run start
oryarn start
- Happy hacking and remain awesome 🤓.
- ISC -
We use the ISC License with ❤️.