express-api-kit
v2.0.2
Published
π Production-Ready Express API Generator - Create enterprise-grade APIs with authentication, file uploads, cron jobs, database pooling, and advanced security features. Supports MongoDB, MySQL, and PostgreSQL.
Downloads
36
Maintainers
Readme
Express API Kit
βββββββββββ ββββββββββ βββββββ ββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββ ββββββ ββββββββββββββββββββββ ββββββββββββββββ
ββββββ ββββββ βββββββ ββββββββββββββ ββββββββββββββββ
ββββββββββββ ββββββ βββ βββββββββββββββββββββββββββ
βββββββββββ ββββββ βββ βββββββββββββββββββββββββββ
ββββββ βββββββ βββ βββ βββββββββββββββ
βββββββββββββββββββ βββ ββββββββββββββββ
βββββββββββββββββββ βββββββ βββ βββ
βββββββββββββββ βββ βββββββ βββ βββ
βββ ββββββ βββ βββ ββββββ βββ
βββ ββββββ βββ βββ ββββββ βββ π Production-Ready Express API Generator - A powerful CLI tool that generates enterprise-grade Express.js APIs with advanced features including authentication, file uploads, cron jobs, database pooling, and comprehensive security middlewares.
π¦ Installation
Install globally for easy access:
npm install -g express-api-kitOr use directly with npx:
npx express-api-kitπ Quick Start
Generate a new API project:
npx express-api-kitFollow the interactive prompts:
? Enter project name: my-awesome-api
? Select database: MongoDBThen start developing:
cd my-awesome-api
npm run dev⨠Advanced Features
π Authentication & Authorization
- JWT-based authentication with role-based access control
- Password hashing with bcryptjs
- User validation and middleware protection
- Customizable authentication flows
π File Upload System
- Multer-powered file upload middleware
- Configurable upload destinations and file types
- File size validation and error handling
- Automatic URL generation for uploaded files
β° Cron Job Scheduler
- Node-cron integration for background tasks
- Predefined job templates (daily, hourly, weekly)
- Custom job creation utilities
- Environment-based job control
ποΈ Database Optimization
- Connection Pooling for both SQL and MongoDB
- Advanced connection management
- Retry mechanisms and error handling
- Performance monitoring and statistics
π‘οΈ Security & Performance
- Helmet.js for security headers
- Rate limiting with express-rate-limit
- Request compression (gzip)
- Input validation with Joi
- CORS configuration
π§ Communication & Logging
- Nodemailer email service integration
- Winston-based structured logging
- Request/response logging with Morgan
- Custom response handlers
π Interactive Setup
The CLI will prompt you for:
- Project Name (default: express-api-kit)
- Database Selection (MongoDB, MySQL, PostgreSQL)
π Project Structure
Generated projects include a comprehensive, production-ready structure:
project-name/
βββ config/
β βββ database.js # Database connection with pooling
βββ controllers/
β βββ auth.controller.js # Authentication logic
βββ docs/
β βββ readme.md # API documentation
βββ jobs/
β βββ exampleCronJob.js # Cron job templates
β βββ jobScheduler.js # Job management system
βββ middlewares/
β βββ auth.middleware.js # JWT & role-based authentication
β βββ upload.middleware.js # File upload handling
βββ models/
β βββ User.js # Database models (Sequelize/Mongoose)
βββ routes/
β βββ auth.routes.js # API route definitions
βββ services/
β βββ emailService.js # Email integration (Nodemailer)
β βββ fileService.js # File operations utilities
βββ utils/
β βββ banner.js # ASCII startup banner
β βββ logger.js # Winston logging configuration
β βββ responseHandler.js # Standardized API responses
βββ view/ # View templates (SQL template only)
βββ .env # Environment variables
βββ .gitignore # Git ignore rules
βββ app.js # Express application setup
βββ package.json # Dependencies & npm scripts
βββ server.js # Application entry pointπ Folder Descriptions
config/- Database connections, app configurationscontrollers/- Request handlers and business logicdocs/- API documentation and guidesjobs/- Background jobs and cron schedulersmiddlewares/- Express middlewares (auth, upload, validation)models/- Database schemas and modelsroutes/- API endpoint definitionsservices/- Reusable business servicesutils/- Helper functions and utilitiesview/- Template files (SQL template only)
π Environment Configuration
A comprehensive .env file is automatically generated with optimized defaults:
MongoDB Template:
# Server Configuration
PORT=5000
NODE_ENV=development
APP_URL=http://localhost:5000
# Database
MONGO_URI=mongodb://localhost:27017/project-name
# Authentication
JWT_SECRET=your_jwt_secret_here_minimum_32_characters
# Email Service
[email protected]
EMAIL_PASS=your_app_password
# MongoDB Connection Pool Settings
MONGO_MAX_POOL_SIZE=10
MONGO_MIN_POOL_SIZE=5
MONGO_MAX_IDLE_TIME=30000
MONGO_SERVER_SELECTION_TIMEOUT=5000
MONGO_SOCKET_TIMEOUT=45000
MONGO_CONNECT_TIMEOUT=10000
MONGO_HEARTBEAT_FREQUENCY=10000
MONGO_READ_PREFERENCE=primary
MONGO_WRITE_CONCERN=majority
MONGO_READ_CONCERN=majority
MONGO_WRITE_TIMEOUT=5000
# Background Jobs
ENABLE_CRON_JOBS=trueSQL Template (MySQL/PostgreSQL):
# Server Configuration
PORT=5000
NODE_ENV=development
APP_URL=http://localhost:5000
# Database
DB_HOST=localhost
DB_USER=root
DB_PASS=password
DB_NAME=project-name
DB_DIALECT=mysql
# Authentication
JWT_SECRET=your_jwt_secret_here_minimum_32_characters
# Email Service
[email protected]
EMAIL_PASS=your_app_password
# Database Connection Pool Settings
DB_POOL_MAX=5
DB_POOL_MIN=0
DB_POOL_ACQUIRE=30000
DB_POOL_IDLE=10000
# Background Jobs
ENABLE_CRON_JOBS=trueπ Running Your Project
After generation, navigate to your project and start developing:
cd my-awesome-api
npm run dev # Development mode with nodemon
# or
npm start # Production modeYou'll see the beautiful startup banner:
================================================================================
βββββββββββ ββββββββββ βββββββ ββββββββββββββββββββββββ
EXPRESS API KIT - Production Ready API Server
================================================================================
π Server running on http://localhost:5000
π API Documentation: http://localhost:5000/api-docs
π Connection Pool: Max 10, Min 5
β‘ Ready to handle requests!π― Built-in API Endpoints
Authentication Routes
POST /api/auth/register # User registration
POST /api/auth/login # User authentication
GET /api/auth/profile # Get user profile (protected)π¦ Included Dependencies
Core Framework
- express - Fast, unopinionated web framework
- cors - Cross-Origin Resource Sharing
- morgan - HTTP request logger
Database & ORM
- mongoose (MongoDB) / sequelize (SQL)
- mysql2 / pg - Database drivers
Security & Authentication
- bcryptjs - Password hashing
- jsonwebtoken - JWT token management
- helmet - Security headers
- express-rate-limit - Rate limiting
File Handling & Jobs
- multer - File upload middleware
- node-cron - Task scheduling
Utilities & Performance
- joi - Input validation
- compression - Response compression
- winston - Advanced logging
- nodemailer - Email service
Development Tools
- nodemon - Development auto-restart
- eslint - Code linting
- prettier - Code formatting
π What You Get Out of the Box
β
Authentication System - Complete JWT-based auth with role management
β
File Upload API - Ready-to-use file upload with validation
β
Background Jobs - Cron job system for scheduled tasks
β
Database Optimization - Connection pooling and retry mechanisms
β
Security Features - Rate limiting, helmet, input validation
β
Professional Logging - Structured logging with Winston
β
Email Integration - Nodemailer setup for notifications
β
API Documentation - Swagger UI ready to customize
β
Production Ready - Optimized configurations and error handling
π Performance Features
- Connection Pooling: Optimized database connections
- Request Compression: Automatic gzip compression
- Rate Limiting: Protection against abuse
- Caching Headers: Efficient client-side caching
- Error Handling: Comprehensive error management
- Health Monitoring: Built-in health check endpoints
π οΈ Customization
All generated code is fully customizable:
- Modify authentication logic in
controllers/auth.controller.js - Add new cron jobs in
jobs/directory - Configure file uploads in
middlewares/upload.middleware.js - Adjust database settings in
config/database.js - Extend API routes in
routes/directory
π€ Contributing
We welcome contributions! Please feel free to submit issues and pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Support & Credits
π¨βπ» Developed by: Muhammad Ahmad
π’ If you like this tool, give it a β on GitHub!
π Report issues: GitHub Issues
π¬ Discussions: GitHub Discussions
Happy Coding! π
Built with β€οΈ for the developer community.
