Built by dhirajsuthar781
A scalable, modular, and production-ready REST API boilerplate using:
- 🟨 Express.js (ES Modules)
- 🧩 Zod for request validation
- 🧠 Modular folder structure
- 🚦 In-memory rate limiter (per-route configurable)
- 🔐 Environment-based configuration (like Vite)
git clone https://github.com/ScremingAlien/express-rest-api-production-grade-project.git
cd express-rest-api-production-grade-project
npm installIn development .env file will be used for Environment variables
npm run dev
In development .env.production file will be used for Environment variables
npm run start
This template provides a structured and scalable architecture for building backend applications. It emphasizes modularity, making it easy to organize and extend your project.
- Modular Structure: Modules are organized within the
src/modules/directory, promoting clear separation of concerns. - Helper Script: A convenient
npm run cmscript is included for quickly generating the basic file structure for new modules. - Organized Files: Each module includes dedicated files for controllers, services, models, and routes.
- Express.js Routing: Utilizes Express.js Router for defining module-specific routes.
- Scalability: The modular design facilitates the addition of new features and the growth of your application.
-
Clone the repository:
git clone <repository-url> cd <repository-name>
-
Install dependencies:
npm install
The template includes a helper script to streamline the creation of new modules.
-
Run the
createModulescript:npm run cm <module-name>
Replace
<module-name>with the desired name for your new module (e.g.,user,product,order).Example: To create a
usermodule, run:npm run cm user
-
Generated File Structure: The Above script will automatically generate the following file structure within the
src/modules/directory:src/ └── modules/ └── user/ ├── user.controller.js ├── user.service.js ├── user.model.js └── user.routes.js
Once you've created a new module, you need to integrate its routes into the main application routing.
After that you have to inject the routes of newly created module in src/app.js