create-mern-backend
v1.0.2
Published
CLI to scaffold MERN backend folder structure with .env and server.js
Downloads
23
Maintainers
Readme
create-mern-backend 🛠️
A zero-config CLI tool to scaffold production-ready MERN stack backend applications with best practices.
🚀 Features
- ⚡ Instant setup – Spin up a MERN backend project in seconds
- 📁 Modular architecture – Clean and scalable folder structure
- 🔐 Secure by default – Configured with CORS, dotenv, and Helmet
- 🔌 MongoDB ready – Pre-wired database connection
- 📦 Lightweight – Only essential dependencies included
📦 Installation
Quick Start (Recommended)
npx create-mern-backend@latestGlobal Installation
npm install -g create-mern-backend
create-mern-backendProject Structure 🌳
my-mern-backend/
├── config/
│ └── db.js # MongoDB connection config
├── controllers/ # Route controllers
├── models/ # Mongoose models
├── routes/ # API route definitions
├── middlewares/ # Custom middleware
├── utils/ # Utility functions
├── .env # Environment variables
├── .gitignore # Git ignore rules
└── server.js # Express server entry pointGenerated Configuration ⚙️
server.js
const express = require("express");
require("dotenv").config();
const app = express();
// Middleware
app.use(express.json());
app.use(cors());
// Database connection
require("./config/db")();
// Basic route
app.get("/", (req, res) => res.send("MERN Backend Running"));
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));.env Template
# Server Configuration
PORT=5000
# MongoDB
MONGO_URI=your_mongodb_connection_string
# Authentication
JWT_SECRET=your_random_secret_key
JWT_EXPIRE=30dDevelopment Scripts 🛠️
After scaffolding:
cd your-project-name
npm install
npm startWhy Use This? 🤔
- Saves hours of manual setup
- Implements industry best practices
- Easily extensible architecture
- Perfect for:
- Prototyping
- Hackathons
- Production applications
- Learning MERN stack
Contributing 🤝
Pull requests are welcome! Please open an issue first to discuss changes.
License 📄
MIT © Vikash Bharal
