Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/manju1807/node-ts-express-template

A robust and secure Express.js boilerplate with TypeScript, featuring advanced security middleware, MongoDB integration, and tools for building production-ready Node.js apps.
https://github.com/manju1807/node-ts-express-template

advance-security boilerplate cors data-sanitization expressjs helmet mongoose nodejs nosql-injection produc product-ready secure-backend template typescript xss-protection

Last synced: 5 days ago
JSON representation

A robust and secure Express.js boilerplate with TypeScript, featuring advanced security middleware, MongoDB integration, and tools for building production-ready Node.js apps.

Awesome Lists containing this project

README

        

# Secure Node.js Express.js & TypeScript Boilerplate ๐Ÿ›ก๏ธ

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.

## ๐Ÿš€ Features

- **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)

## ๐Ÿ“‹ Prerequisites

- Node.js (v14+ recommended)
- MongoDB

## ๐Ÿ› ๏ธ Installation

1. Clone the repository:

```bash
git clone https://github.com/manju1807/node-ts-express-template.git
```

2. Install dependencies:

```bash
npm install
```

3. Create a `.env` file in the root directory and add your environment variables:

```bash
MONGODB_URI=your_mongodb_connection_string
PORT=3000
NODE_ENV=development
```

4. Start the development server:

```bash
npm run dev
```

## ๐Ÿšฆ API Routes

All routes are prefixed with `/api/v1`. Add your routes in `src/routes/index.ts`.

## ๐Ÿ›ก๏ธ Security

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

## ๐Ÿ› Debugging

Use the `debug` package for debugging. Start your application with:

```bash
DEBUG=app:* npm start
```

## ๐Ÿค Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

## ๐Ÿ˜Ž Author

Manjunath R

## ๐Ÿ“œ License

This project is MIT licensed.