create-new-express-project
v3.1.1
Published
CLI to create express app in MVC pattern
Maintainers
Readme
🚀 Express MVC Starter
Express.js starter boilerplate with MVC architecture
📝 Introduction
A professional Express.js starter boilerplate designed for scalable and production-ready Node.js applications. It provides a clean MVC structure, multiple database templates, validation options, developer tooling, and deployment support.
📦 Features
✅ Express.js – Fast, minimalist web framework
✅ MVC Architecture – Clean separation of Models, Views, Controllers
✅ Multiple Database Templates – MySQL, PostgreSQL, Mongoose (MongoDB), Sequelize
✅ Validators – Joi or express-validator (configurable)
✅ Environment Config – dotenv-based configuration
✅ Security – Helmet, CORS, Rate Limiting
✅ Logging – Centralized logger with levels & transports
✅ File Uploads – Multer integration
✅ Mail Service – Nodemailer support
✅ API Documentation – Swagger (OpenAPI)
✅ Testing – Jest setup out of the box
✅ Linting & Formatting – ESLint & Prettier
✅ Process Management – PM2 for production
✅ Hot Reloading – nodemon for development
🧩 Templates
You can choose a database template during project creation:
- MySQL – Traditional relational database setup
- PostgreSQL – Advanced relational database with strong consistency
- Mongoose – MongoDB ODM for NoSQL applications
- Sequelize – ORM supporting MySQL, PostgreSQL, and more
Language support:
- JavaScript (default)
- TypeScript (recommended for large & scalable projects)
🧪 Validators
Validation can be enabled during setup (fully supported in JavaScript & TypeScript):
- Joi – Schema-based request validation
- express-validator – Middleware-based validation for Express routes
🛠 Tools Included
- ESLint & Prettier – Code quality and formatting
- Nodemailer – Email sending utility
- Multer – File upload handling
- Jest – Unit and integration testing
- Swagger – API documentation and testing UI
- PM2 – Production process manager
- nodemon – Auto-restart server during development
⚙️ Installation
Create a new project using NPX or NPM:
npx create-new-express-project <project-name>
# or
npm create new-express-project <project-name>👍 Help
Usage: create-new-express-project <project-name> [options]
CLI to create Express app in MVC pattern
Options:
-V, --version output the version number
-m, --mongoose Setup Mongoose
-M, --mysql Setup MySQL
-p, --postgres Setup Postgres
-S, --sequelize Setup Sequelize
-h, --help display help for command📋 Interactive Prompts
✔ Preferred language: JavaScript
✔ Select Template: MySQL / PostgreSQL / Mongoose / Sequelize
✔ Choose Validator: Joi / express-validator
✔ Select Tools: Linting / Testing / Swagger / Deployment
After setup:
cd <project-name>
npm install
npm run dev🔧 Environment Configuration
Create a .env file in the root directory:
APP_PORT=3000
NODE_ENV=development
# Database configuration
DB_HOST=localhost
DB_PORT=3306
DB_NAME=app_db
DB_USER=root
DB_PASSWORD=secret
# Mail configuration
MAIL_HOST=smtp.example.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=your_password🚦 Running the Application
# Development mode (nodemon)
npm run dev
# Production mode
npm start
# Run tests
npm run testServer will start at: 👉 http://localhost:3000
📜 NPM Scripts
| Command | Description |
| -------------------- | ---------------------------------------- |
| npm run dev | Start with nodemon |
| npm start | Run app in production |
| npm run build | Compile TypeScript to JavaScript |
ESLint & Prettier
| Command | Description |
| ----------------------- | ------------------------------------- |
| npm run lint | Run ESLint to check code quality |
| npm run lint:fix | Automatically fix ESLint issues |
| npm run format | Check code formatting using Prettier |
| npm run format:fix | Format code using Prettier |
Testing
| Command | Description |
| ----------------------- | ------------------------------------- |
| npm run test | Run unit tests with Jest |
| npm run test:coverage | Run tests with coverage reports |
Database Migrations (Sequelize)
| Command | Description |
| --------------------- | ----------------------------------------------- |
| npm run db:migrate | Create database tables based on model files |
| npm run db:refresh | Drop all tables and recreate from model files |
| npm run db:seed | Populate database with seed data |
Deployment (PM2)
| Command | Description |
| ----------------------- | ------------------------------------- |
| npm run pm2:start | Start application with PM2 |
| npm run pm2:restart | Restart PM2 process |
| npm run pm2:stop | Stop PM2 process |
📖 API Documentation
Swagger UI is available at: 👉 http://localhost:3000/api-docs
🗂 Folder Structure
my-express-app/
│
├── src/
│ ├── config/ # App, database, and environment configs
│ ├── controllers/ # Request handlers (business logic)
│ ├── models/ # Database models / schemas
│ ├── repositories/ # Database query layer
│ ├── routes/ # API route definitions
│ ├── middlewares/ # Custom Express middlewares
│ ├── validators/ # Joi / express-validator schemas
│ ├── services/ # Reusable services (mail, file upload, etc.)
│ ├── utils/ # Helper utilities (logger, constants)
│ ├── public/ # Static assets
│ ├── tests/ # Unit & integration tests
│ ├── views/ # View templates (if enabled)
│ ├── app.js # Express app entry
│ └── server.js # Application bootstrap
│
├── uploads/ # Uploaded files (multer)
├── swagger.yaml # Swagger API documentation
├── ecosystem.config.js # PM2 configuration
├── .env.example # Environment variable sample
└── package.json
🧰 Tech Stack
- Node.js
- Express.js
- MySQL / PostgreSQL / MongoDB
- Sequelize / Mongoose
- Joi / express-validator
- Multer
- Nodemailer
- Swagger (OpenAPI)
- Jest
- PM2
🧾 License
This project is licensed under the MIT License – free to use and modify.
🌟 Contributing
Contributions, issues, and feature requests are welcome! Feel free to open a pull request.
💡 Author
Karthikeyan M 👨💻 GitHub
