This is a boilerplate project that provides a secure starting point for building web applications with Node.js (Express.js) and MongoDB (Mongoose). It also includes a Docker container for easy deployment and scalability, as well as Redis for rate limiting.
- NoSQL database: MongoDB object data modeling using Mongoose
- Security: set security HTTP headers using helmet
- Santizing: sanitize request data against xss, query injections and HTTP parameter pollution using xss-clean, express-mongo-sanitize & hpp
- Rate Limiting: prevent small DDOS and Brute-Force Attacks using rate-limiter-flexible
- CORS: Cross-Origin Resource-Sharing enabled using cors
- Error handling: centralized and async error handling mechanism with a custom error class
- Compression: gzip compression with compression
- Logging: using morgan
- Docker support: for easy deployment and scalability
- Best Practices: Async catch handler, Directory Structure, Validation
- Node.js (version 12 or higher)
- MongoDB Database
- Docker
- Clone the repository to your local machine:
git clone https://github.com/0xBitBuster/express-mongoose-boilerplate.git
- Set environment variables in
docker-compose.dev.yaml
anddocker-compose.yaml
To start the server, run:
docker-compose up [-f docker-compose.dev.yaml]
By default, the server runs on http://localhost:80
Contributions are welcome! If you have a feature request or bug report, please open an issue. If you want to contribute code, please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.