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#readmecors-https://github.com/expressjs/cors#readmedotenv-https://github.com/motdotla/dotenv#readmehelmet-https://helmetjs.github.io/mongoDB-https://www.mongodb.com/mongoose-https://mongoosejs.com/morgan-https://github.com/expressjs/morgan#readmewinston-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 ioryarn install
- Create the following environment variables manually or by copying the
.env.examplefile to a.envfile:- To auto generate a .env use:
npm run generate-envoryarn 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 devoryarn dev
- Test application locally and ensure all tests pass with 100% coverage.
npm run testoryarn test- To generate a web based view of the coverage use:
npm run test-publishoryarn test-publish
- To generate an updated .env.example.
npm run update-example-envoryarn update-example-env
- To generate documentation using JSDocs.
npm run update-documentationoryarn update-documentation
- Run in a production environment
npm run startoryarn start
- Happy hacking and remain awesome 🤓.
- ISC -
We use the ISC License with ❤️.