express-setup-kit
v1.0.0
Published
Basic Express.js setup generator with ready-to-use server boilerplate.
Maintainers
Readme
🚀 Express Setup Kit
⚡ A powerful CLI tool to instantly scaffold a production-ready Express.js server with best practices and modern folder structure.
Say goodbye to repetitive Express.js setup! Express Setup Kit generates a complete, organized Express server boilerplate in seconds, so you can focus on building your application logic rather than configuring the basics.
✨ Features
- 🎯 Zero Configuration - Get started instantly with sensible defaults
- 📁 Organized Structure - Professional folder organization following industry standards
- 🔒 Security First - Comes with Helmet.js and CORS pre-configured
- 📊 Logging Ready - Morgan logger integrated for request tracking
- 🌍 Environment Variables - Dotenv setup with .env file generation
- 🚀 Hot Reload - Nodemon configured for development workflow
- 🏥 Health Check - Built-in health endpoint for monitoring
- 🛡️ Error Handling - Centralized error handling middleware
- 💾 Database Ready - Placeholder for database connection setup
📦 Installation
Global Installation (Recommended)
npm install -g express-setup-kitOne-time Usage with npx
npx express-setup-kit🚀 Quick Start
Run the CLI tool:
express-setup-kitEnter your project name when prompted (default: "server")
Install dependencies when asked (recommended: Yes)
Navigate to your project and start coding:
cd your-project-name npm run dev
Your Express server will be running at http://localhost:8080 🎉
📋 What Gets Generated
📁 Project Structure
your-project/
├── src/
│ ├── config/
│ │ └── db.js # Database configuration
│ ├── controllers/ # Route controllers
│ ├── middlewares/
│ │ └── errorHandler.js # Centralized error handling
│ ├── models/ # Data models
│ ├── routes/ # API routes
│ ├── utils/ # Utility functions
│ └── server.js # Main application file
├── .env # Environment variables
└── package.json # Dependencies and scripts🛠️ Generated Files
src/server.js - Main Application
- Express app configuration
- Middleware setup (CORS, Helmet, Morgan)
- Health check endpoint (
/health) - Welcome route (
/) - Error handling middleware
- Server startup logic
src/config/db.js - Database Configuration
- Database connection placeholder
- Ready to integrate with MongoDB, PostgreSQL, MySQL, etc.
src/middlewares/errorHandler.js - Error Handling
- Centralized error handling middleware
- Proper error responses and logging
.env - Environment Variables
- PORT configuration (default: 8080)
- Ready for additional environment variables
📦 Included Dependencies
Production Dependencies:
- express
^4.18.2- Fast, unopinionated web framework - cors
^2.8.5- Cross-Origin Resource Sharing middleware - helmet
^7.0.0- Security middleware for HTTP headers - morgan
^1.10.0- HTTP request logging middleware - dotenv
^16.0.3- Environment variable loader
Development Dependencies:
- nodemon
^3.1.0- Auto-restart during development
🎯 Available Scripts
npm start # Start production server
npm run dev # Start development server with auto-reload🔧 Customization
Environment Variables
The generated .env file includes:
PORT=8080Add more variables as needed:
PORT=8080
NODE_ENV=development
DB_URL=mongodb://localhost:27017/myapp
JWT_SECRET=your-secret-keyDatabase Integration
Replace the placeholder in src/config/db.js:
MongoDB Example:
import mongoose from 'mongoose';
export const connectDB = async () => {
try {
await mongoose.connect(process.env.DB_URL);
console.log('✅ MongoDB connected successfully');
} catch (error) {
console.error('❌ Database connection failed:', error.message);
process.exit(1);
}
};PostgreSQL Example:
import pkg from 'pg';
const { Pool } = pkg;
const pool = new Pool({
connectionString: process.env.DB_URL,
});
export const connectDB = async () => {
try {
await pool.connect();
console.log('✅ PostgreSQL connected successfully');
} catch (error) {
console.error('❌ Database connection failed:', error.message);
process.exit(1);
}
};🛣️ Adding Routes
Create route files in src/routes/:
// src/routes/users.js
import express from 'express';
const router = express.Router();
router.get('/', (req, res) => {
res.json({ message: 'Users endpoint' });
});
router.post('/', (req, res) => {
// Create user logic
res.json({ message: 'User created' });
});
export default router;Import and use in server.js:
import userRoutes from './routes/users.js';
app.use('/api/users', userRoutes);🏥 Health Check
The generated server includes a built-in health check endpoint:
GET /healthResponse:
{
"status": "OK",
"message": "All systems operational",
"timestamp": "2025-09-28T10:30:00.000Z"
}🔒 Security Features
- Helmet.js - Sets various HTTP headers for security
- CORS - Configurable Cross-Origin Resource Sharing
- Error Handling - Prevents sensitive information leakage
- Input Validation - Express built-in body parsing with limits
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📝 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙋♂️ Author
Arpit Rai
- GitHub: @arpitr18
⭐ Show Your Support
Give a ⭐️ if this project helped you!
📚 Changelog
v1.0.0
- Initial release
- Basic Express.js server generation
- Folder structure scaffolding
- Essential middleware integration
- Environment variable setup
