Introduction
xpress-generator is a professional CLI tool that scaffolds a complete, production-ready Express.js backend in one command.
Instead of spending hours wiring up authentication, error handling, database connections, migrations, Docker, testing, and linting from scratch — xpress-generator generates a well-structured project with all of that already configured, so you can start building features immediately.
npx xpress-generator create MyApp
Philosophy​
xpress-generator is built around three core ideas:
1. Zero config, full setup​
Answer a few questions and get a project that actually works — including auth routes, a database connection, migrations, Docker, middleware, and tests.
2. Opinionated but flexible​
The generated project follows professional conventions (clean module architecture, separate server.js from app.js, service layer, centralized error handling) but every file is yours to modify.
3. Professional from the start​
Every project is generated with testing, migrations, Docker, linting, and pre-commit hooks already configured. No shortcuts.
What gets generated​
When you run npx xpress-generator create MyApp and answer the prompts, you get:
| Category | What's included |
|---|---|
| Architecture | Clean module structure — src/modules/, src/shared/, src/middleware/ |
| Auth | JWT login/logout, refresh tokens (httpOnly cookie), verifyToken, requireRole, rate limiting |
| Error handling | AppError class, global errorHandler middleware, catchAsync wrapper |
| Validation | Zod schema + reusable validate middleware |
| Database | Config file + model + service for your chosen DB |
| Migrations | Sequelize CLI (MySQL/PostgreSQL) or custom SQL runner (SQL Server) |
| Docker | Multi-stage Dockerfile + docker-compose.yml tailored to your database |
| Testing | Jest + supertest, tests/setup.js, example integration test, 70% coverage threshold |
| Linting | ESLint config (+ @typescript-eslint for TS projects) |
| Pre-commit | Husky + lint-staged auto-configured and ready |
| TypeScript | Full .ts templates, tsconfig.json, ts-node, ts-jest, all @types/* |
Supported databases​
| Database | Driver / ORM | Migrations |
|---|---|---|
| MongoDB | Mongoose | — (schema-less) |
| MySQL | Sequelize + mysql2 | Sequelize CLI |
| PostgreSQL | Sequelize + pg | Sequelize CLI |
| SQL Server | mssql | Custom SQL runner |
CLI at a glance​
# Create a new project
npx xpress-generator create [name]
# Generate a full CRUD module (model + service + controller + routes + schema)
npx xpress-generator generate:model <ModelName>
npx xpress-generator g:model <ModelName> # alias
# Generate a custom middleware
npx xpress-generator generate:middleware <name>
npx xpress-generator g:middleware <name> # alias
Head to Getting Started to create your first project in under 2 minutes.