express-backend-starter
v1.0.2
Published
A production-ready CLI tool to scaffold Express.js/Node.js backend projects
Maintainers
Readme
🚀 Express Backend Starter CLI
A production-ready CLI tool to scaffold Express.js/Node.js backend projects in seconds.
✨ Features
- 🎯 Interactive Setup - Guided prompts for project configuration
- 🗄️ Multiple Databases - MongoDB, PostgreSQL, or MySQL support
- 📚 Swagger Docs - Auto-generated API documentation
- ✅ Zod Validation - Type-safe request validation
- 📧 Email Support - Nodemailer integration
- 🔒 Security First - Helmet, CORS, rate limiting, JWT auth
- 📁 Clean Architecture - Professional folder structure
- ⚡ Production Ready - Best practices built-in
🚀 Quick Start
Using npx (Recommended)
npx express-backend-starterOr Install Globally
npm install -g express-backend-starter
express-backend-starter📋 What Gets Generated?
Always Included
- ✅ Express.js server setup
- ✅ JWT authentication middleware
- ✅ Error handling middleware
- ✅ CORS configuration
- ✅ Rate limiting
- ✅ Helmet security headers
- ✅ Cookie parser
- ✅ Bcrypt password hashing
- ✅ File upload with Multer
- ✅ Environment configuration
- ✅ Professional folder structure
Database Options
- MongoDB → Mongoose ORM
- PostgreSQL → Prisma ORM
- MySQL → Prisma ORM
Optional Features
- 📚 Swagger → API documentation UI
- ✅ Zod → Runtime validation
- 📧 Nodemailer → Email functionality
🎬 Demo
$ npx express-backend-starter
🚀 Welcome to Express Backend Starter CLI
Let's scaffold your backend project...
? What is your project name? my-awesome-api
? Which database do you want to use? MongoDB
? Include Swagger documentation? Yes
? Include Zod validation? Yes
? Include Nodemailer for email functionality? No
✅ Project created successfully!
Next steps:
cd my-awesome-api
npm run dev
Happy coding! 🎉📁 Generated Project Structure
my-awesome-api/
├── .env.example
├── .gitignore
├── README.md
├── package.json
└── src/
├── app.js # Main application
├── config/
│ ├── db.js # Database connection
│ └── swagger.js # Swagger config (optional)
├── controllers/
│ └── healthController.js # Sample controller
├── middleware/
│ ├── auth.js # JWT authentication
│ └── errorHandler.js # Global error handler
├── models/
│ └── User.js # Sample model
├── routes/
│ └── healthRoutes.js # Sample routes
├── services/ # Business logic
└── utils/
└── validation.js # Zod schemas (optional)🛠️ Tech Stack
- Framework: Express.js
- Authentication: JWT (jsonwebtoken)
- Security: Helmet, CORS, express-rate-limit
- Password Hashing: bcryptjs
- File Upload: Multer
- Database ORMs: Mongoose (MongoDB) or Prisma (PostgreSQL/MySQL)
- Documentation: Swagger (optional)
- Validation: Zod (optional)
- Email: Nodemailer (optional)
📖 Usage
1. Run the CLI
npx express-backend-starter2. Answer the Prompts
The CLI will ask you:
- Project name
- Database choice (MongoDB/PostgreSQL/MySQL)
- Include Swagger? (y/n)
- Include Zod? (y/n)
- Include Nodemailer? (y/n)
3. Navigate to Your Project
cd your-project-name4. Configure Environment
cp .env.example .env
# Edit .env with your settings5. For Prisma (PostgreSQL/MySQL)
npx prisma migrate dev
npx prisma generate6. Start Development
npm run devYour server will be running at http://localhost:5000
🌐 API Endpoints
Generated project includes:
GET /- Welcome messageGET /api/health- Health checkGET /api/health/info- Server infoGET /api-docs- Swagger UI (if enabled)
🔧 Available Scripts
{
"dev": "nodemon src/app.js", // Development with auto-reload
"start": "node src/app.js" // Production start
}🔐 Environment Variables
The generated .env.example includes:
PORT=5000
NODE_ENV=development
JWT_SECRET=your_secret_key
JWT_EXPIRE=7d
# Database URLs (based on your choice)
MONGO_URI=mongodb://localhost:27017/dbname
# or
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
# Optional
EMAIL_HOST=smtp.gmail.com
[email protected]
# ... and more📚 Documentation
For detailed development guide, see devGuide.md
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
MIT License - see LICENSE file for details
🙏 Credits
Built with:
💬 Support
If you have any questions or issues, please open an issue on GitHub.
Made with ❤️ for the Node.js community
