A production-ready Node.js Express boilerplate with TypeScript, featuring robust architecture, Prisma ORM with generic repository pattern and Object-Oriented Programming (OOP) principles.
- TypeScript Support - Written in TypeScript for better developer experience and type safety.
- Express.js - Fast, unopinionated web framework for Node.js.
- Prisma ORM - Database access with a Generic Repository Pattern, following OOP principles for better maintainability and reusability.
- Redis Integration - Redis support for caching to improve performance.
- Error Handling - Centralized global error handling middleware.
- API Documentation - Auto-generated route documentation.
- Code Quality
- ESLint for code linting.
- Prettier for code formatting.
- Event System - Built-in event handling system for better modularization.
- Middleware - Common middleware implementations:
- Authentication middleware.
- Error handling middleware.
- Rate limiting middleware.
- Pagination middleware.
- Request validation middleware.
- Postman Collection -
Broilerplate.postman_collection.json
included for API testing. - Object-Oriented Architecture - Designed with OOP principles, ensuring modularity, reusability, and scalability.
- Node.js (v16 or higher)
- npm or yarn
- Redis server
- PostgreSQL or any database supported by Prisma
-
Clone the repository:
git clone <repository-url> cd <project-name>
-
Install dependencies:
npm install # or yarn install
-
Setup environment variables:
cp .env.example .env
- Open
.env
and update the configuration as needed.
- Open
-
Generate Prisma client:
npm run prisma:generate
-
Run database migrations:
npm run prisma:migrate:dev
-
Seed the database with initial data:
npm run prisma:seed
src/
├── app/
│ ├── middlewares/ # Express middlewares
│ ├── modules/ # Feature modules
│ │ └───├── constants/
│ │ ├── controllers/
│ │ ├── helpers/
│ │ ├── interfaces/
│ │ ├── routes/
│ │ ├── services/
│ │ └── router.ts
│ └── index.ts # Express app configuration
├── config/ # Configuration files
├── shared/ # Shared utilities and helpers
├── types/ # TypeScript type definitions
└── server.ts # Application entry point
npm run dev
# or
yarn dev
- Generate Prisma client
npm run prisma:generate
- Run migrations (development)
npm run prisma:migrate:dev
- Reset database
npm run prisma:db:reset
- Open Prisma Studio
npm run prisma:studio
- Seed database
npm run prisma:seed
- The application automatically logs all available routes.
- Use the provided Postman Collection (
Broilerplate.postman_collection.json
) to test API endpoints.
The application includes a centralized error-handling system. Any error that occurs is caught and formatted before being sent to the client, ensuring a standardized response structure.
This boilerplate includes several security enhancements:
- Helmet.js for setting security headers.
- Rate Limiting to prevent excessive API requests.
- CORS Configuration for cross-origin security.
- Disabled
x-powered-by
Header to mask Express usage. - Request Size Limiting to prevent large payload attacks.
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
feature/your-feature
orfix/your-fix
). - Commit your changes.
- Push the branch and create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.