create-setup-express-backend
v4.0.3
Published
CLI to bootstrap a customizable Node.js API starter with optional MongoDB, Helmet, and folder structure. Express is always included.
Maintainers
Readme
🚀 Quick Start (Recommended)
Run the CLI instantly using npx instead of npm i:
npx create-setup-express-backend🚀 create-setup-express-backend
A professional CLI tool to instantly scaffold a modern Express.js backend with optional MongoDB, Helmet security, recommended folder structure, auto environment setup, and optional demo APIs.
Built with ❤️ by Piyush Gupta to help developers ship backend projects faster, cleaner, and more efficiently.
📌 Table of Contents
- ✨ Overview
- 🔥 Features
- ⚙️ Installation
- 🚀 Usage
- 🎥 Demo (CLI GIF)
- 📁 Folder Structure
- 🧠 server.js Example
- 🛢️ MongoDB Setup
- 🛡️ Helmet Security
- 📝 Environment Variables
- 📘 Advanced Usage
- 🛠️ Troubleshooting
- 🏗️ Versioning Guide
- 🤝 Contributing
- 📄 License
- 👨💻 Author
- ⭐ Support
✨ Overview
create-setup-express-backend is a CLI tool that generates a full Express backend structure in seconds.
It eliminates repetitive setup work like:
- installing packages
- setting up environment files
- creating project folders
- configuring MongoDB
- adding security layers
- building demo routes + controllers
Generate a backend in less than 10 seconds.
🔥 Features
🟢 Always Included
| Feature | Description |
| -------------------- | ----------------------------------------- |
| 🚀 Express.js | Always installed, pre-configured with ESM |
| 📦 CORS + Dotenv | Included by default |
| 🔄 Nodemon | Auto-installed as dev dependency |
| 📜 Auto server.js | Clean and ready-to-run |
| ⚙️ Auto dependencies | Runs npm install automatically |
🟡 Optional (User Selects)
| Option | Description |
| --------------------- | --------------------------------- |
| 🛢️ MongoDB (Mongoose) | Auto-connects + generates db.js |
| 🛡 Helmet Security | Adds secure headers |
| 📁 Folder Structure | Creates MVC folders |
| 🧩 Demo API Files | Adds example route + controller |
⚙️ Installation
Use via npx (recommended)
npx create-setup-express-backendInstall globally
npm install -g create-setup-express-backend
create-setup-express-backend🚀 Usage
Run:
npx create-setup-express-backendThe CLI then asks:
Project name:
Do you want MongoDB (Mongoose)?
Do you want Helmet?
Create folder structure?
Write demo files?
Default port:After creation:
cd project-name
npm run devYour backend is live at:
http://localhost:5000🎥 Demo (CLI GIF)
You can add a GIF of your CLI here:
📁 Folder Structure
If folder structure is enabled:
my-api/
│
├── server.js
├── .env
│
├── config/
│ └── db.js
│
├── controllers/
│ └── homeController.js
│
├── routes/
│ └── index.js
│
└── models/🧠 server.js Example
import dotenv from "dotenv";
dotenv.config();
import express from "express";
import cors from "cors";
const app = express();
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
res.json({
message: "Server is running 🚀",
createdBy: "Piyush Gupta (create-setup-express-backend)",
});
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`🚀 Server running on port ${PORT}`));🛢️ MongoDB Setup
When MongoDB is enabled, this file is generated:
config/db.js
import mongoose from "mongoose";
const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log("🔥 MongoDB connected:", conn.connection.host);
} catch (err) {
console.error("❌ MongoDB Error:", err.message);
process.exit(1);
}
};
export default connectDB;Automatically imported in server.js when selected.
🛡️ Helmet Security
If enabled:
import helmet from "helmet";
app.use(helmet());Adds common security headers.
📝 Environment Variables
Generated .env:
PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/my_api
NODE_ENV=development📘 Advanced Usage
Generate backend with MongoDB & structure:
npx create-setup-express-backendChoose:
- MongoDB → YES
- Folder structure → YES
- Demo files → YES
Run dev server:
npm run devServer auto-restarts on file change.
📄 License
MIT License — free for personal & commercial use.
👨💻 Author
Piyush Gupta
Full-Stack Developer | Backend Engineer
📧 Email: [email protected]
🔗 LinkedIn: linkedin.com/in/piyush-gupta-06b020213/
💻 GitHub: github.com/hackhub817
⭐ Support
If you like this package:
- ⭐ Star the GitHub repo
- 📦 Use it in your projects
- 🔗 Share it with other developers
- 💬 Post about it on LinkedIn
Made with ❤️ by Piyush Gupta

