Express API Boilerplate
Overview
This is a boilerplate application for building REST APIs in Node.js using ES6 and Express. Helps you stay productive by following best practices.
Features
- Authentication using JsonWebToken
- Authorization
- Code Linting using ESLint and Prettier
- Compression Using gzip compression with Compression
- CORS Cross-Origin Resource-Sharing enabled using Cors
- Database (NoSQL) using MongoDB
- Database Seeder
- Environment Variable using dotenv
- Logging using Winston and winston-daily-rotate-file
- Mail Delivery using NodeMailer
- Process Manager (development) using Nodemon
- Process Manager (production) using PM2
- Rate Limitter
- Secure HTTP Headers using Helmet
- Testing using Jest and Supertest
- Validation using ValidatorJS
Directory Structure
•
├── config
│ └── auth.js
│ └── database.js
│ └── environment.js
│ └── mail.js
│ └── server.js
├── database
│ └── connection.js
├── middleware
│ └── error-handler
│ └── validation
├── modules
│ └── <module>
│ └── controller
│ │ └── index.js
│ │ └── create.js
│ │ └── read-all.js
│ │ └── read-one.js
│ │ └── update.js
│ │ └── destroy.js
│ └── middleware
│ └── policy
│ │ └── index.js
│ │ └── create.js
│ │ └── read-all.js
│ │ └── read-one.js
│ │ └── update.js
│ │ └── destroy.js
│ └── rules
│ │ └── create.js
│ │ └── update.js
│ │ └── destroy.js
│ └── service
│ │ └── <module>.service.js
│ └── test
│ └── model.js
│ └── schema.js
│ └── seed.js
│ └── router.js
├── utils
│ └── logger
│ └── mailer
│ └── response-format
├── app.js
├── router.js
└── server.js
Getting Started
...
Installation
...
Quick Start
...
Testing Email
When building complex applications then sooner or later you end up in a situation where you need to send emails from your application in test environment but do not want to accidentally spam anyone.
One solution would be to separate development email addresses and use only some specific testing address to send all mail to but a better approach would be to use a separate email catching service that accepts all messages like a normal transactional SMTP service would but instead of delivering these to destination, it only logs these messages.
There are several options for using such a service, Nodemailer has built-in support for Ethereal Email. You can create new testing account on the fly by using the createTestAccount method or from the Ethereal homepage.
Reference Links: