Install
Install create-express-modular
The exact commands, flags, and files. Choose a one-shot run or a global install — then scaffold in seconds.
Prerequisites
- Node.js
v18+ - One of: npm
v9+, yarnv1.22+, pnpmv8+, or bunv1.0+
Global install (recommended)
Installing globally gives you the short cem command everywhere:
bash
# npm
npm install -g create-express-modular
# yarn
yarn global add create-express-modular
# pnpm
pnpm add -g create-express-modular
# bun
bun add -g create-express-modularVerify it is on your path:
bash
cem --version
cem --helpOne-shot run
If you prefer not to install, run the latest version directly. CEM detects the package manager automatically.
bash
# npm
npx create-express-modular my-api
# yarn
yarn create express-modular my-api
# pnpm
pnpm dlx create-express-modular my-api
# bun
bunx create-express-modular my-apiQuick mode flags
Pass -y or --yes to skip every prompt and scaffold with the recommended stack.
bash
cem my-api -yDefaults applied in quick mode:
- Database / ORM: Mongoose (MongoDB)
- Validator: Zod
- Auth: JWT with HTTP-only cookies
- Docker files included
- Swagger / OpenAPI 3.0 docs included
Override individual choices
bash
# Pick a different database / ORM
cem my-api -y --db prisma
cem my-api -y --db drizzle
# Pick a different validator
cem my-api -y --validator joi
# Skip optional features
cem my-api -y --no-auth
cem my-api -y --no-docker
cem my-api -y --no-swagger
# Skip dependency install (great for CI/CD & custom pipelines)
cem my-api -y --no-install
cem my-api -y --skip-install
# Token delivery style
cem my-api -y --header # Authorization header instead of cookiesWhat gets generated
After the wizard finishes, my-api/ contains a fully wired, domain-driven Express + TypeScript project.
my-api/
├── src/
│ ├── app/
│ │ ├── config/index.ts # typed, centralized config
│ │ ├── config/swagger.ts # OpenAPI 3.0 spec generator (Swagger only)
│ │ ├── errors/ # AppError + error handler
│ │ ├── middlewares/ # auth, rate-limit, error, 404, compression
│ │ ├── modules/ # feature modules (auto-wired)
│ │ │ └── Auth/ # generated when --auth is true
│ │ ├── routes/index.ts # router registry
│ │ └── utils/ # catchAsync, sendResponse, QueryBuilder...
│ ├── app.ts # Express app instance (with compression & guards)
│ └── server.ts # DB connection pool + keep-alive listen
├── .env # local environment variables
├── .env.example # documented env template
├── cem-cli.json # CEM manifest (tracks stack & features)
├── cem-cli.schema.json # JSON Schema for cem-cli.json editor IntelliSense
├── Dockerfile # multi-stage production image
├── docker-compose.yml # local MongoDB / Postgres orchestration
├── eslint.config.js # ESLint v10 flat config rules
├── .prettierrc # format rules
├── tsconfig.json # TypeScript config
└── package.json # deps + scriptsKey files explained
| File | Purpose |
|---|---|
| cem-cli.json | Tracks the chosen stack so later add/remove commands stay consistent. |
| cem-cli.schema.json | JSON Schema providing instant validation and auto-complete in VS Code and other editors. |
| src/app/config/index.ts | One typed place for env vars and app-wide constants. |
| src/app/routes/index.ts | Auto-wires every module's router. New modules plug in here. |
| src/app/errors/AppError.ts | Structured errors with statusCode, message and stack. |
| src/app/middlewares/auth.ts | JWT guard — generated when auth is enabled. |
| src/app/utils/catchAsync.ts | Wraps async route handlers so errors reach the error middleware. |
Run it
bash
cd my-api
npm install
cem devOpen http://localhost:5000 to see the CEM welcome page, health check, and a link to the interactive Swagger docs at /docs.