A robust and secure Express.js boilerplate with TypeScript, featuring advanced security middleware, MongoDB integration, and development tools for building production-ready Node.js applications.
- Express.js with TypeScript: Modern, type-safe backend development
- MongoDB Integration: Easy database setup with Mongoose
- Advanced Security Measures:
- 🔒 Helmet for setting various HTTP headers
- 🌐 CORS support
- 🚦 Rate limiting to prevent abuse
- 🧹 Data sanitization against NoSQL injection and XSS
- 🛑 Parameter pollution prevention
- Environment Configuration: dotenv for easy environment variable management
- Logging: Morgan for HTTP request logging
- Error Handling: Custom error handling middleware
- API Routing: Structured API routing setup
- Development Tools:
- 🐛 Debug for better debugging experience
- 🔄 Nodemon for auto-restarting the server (add to your devDependencies)
- Node.js (v14+ recommended)
- MongoDB
-
Clone the repository:
git clone https://github.com/manju1807/node-ts-express-template.git
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and add your environment variables:MONGODB_URI=your_mongodb_connection_string PORT=3000 NODE_ENV=development
-
Start the development server:
npm run dev
All routes are prefixed with /api/v1
. Add your routes in src/routes/index.ts
.
This boilerplate comes with several security measures:
-* Helmet: Sets various HTTP headers
-* CORS: Configures Cross-Origin Resource Sharing
-* Rate Limiting: Limits repeated requests to public APIs
-* Data Sanitization: Prevents NoSQL injections and XSS attacks
-* Parameter Pollution Prevention: Prevents parameter pollution
Use the debug
package for debugging. Start your application with:
DEBUG=app:* npm start
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
Manjunath R
This project is MIT licensed.