Getting Started
Install & scaffold
Spin up a production-ready Express + TypeScript backend in under a minute.
Prerequisites
- Node.js
v18+ - One of: npm
v9+, yarnv1.22+, pnpmv8+, or bunv1.0+ - A database (MongoDB, PostgreSQL) — local or cloud
Install the CLI (recommended)
Installing globally gives you the short cem executable everywhere in your workspace:
bash
# npm (recommended)
npm install -g create-express-modular
# yarn / pnpm / bun
yarn global add create-express-modular
pnpm add -g create-express-modular
bun add -g create-express-modularScaffold a new project
bash
cem my-apiOr run it without installing anything:
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-apiThe wizard
The CLI asks you a handful of questions to tailor the generated project:
bash
? Project name: my-api
? Database / ORM: Mongoose (MongoDB)
? Validator: Zod (recommended)
? Include JWT Auth module? Yes
? Auth token delivery: HTTP-only cookies (recommended)
? Include Docker setup? Yes
? Include Swagger API docs (OpenAPI 3.0)? YesWhat the CLI does next
- Checks for an existing folder name upfront so nothing is overwritten
- Scaffolds a clean, domain-driven modular structure
- Configures robust database connection pooling and keep-alive timeouts (for Mongoose, Prisma, and Drizzle) with strict environment variable validation (
DATABASE_URL,MONGODB_URI) - Generates
cem-cli.jsonmanifest with its companioncem-cli.schema.jsonfor instant editor IntelliSense - Sets up Express 5 typed routing, ESLint v10 modern flat configuration (
eslint.config.js), Prettier, and HTTP response compression - Runs a single-pass ultra-fast dependency install with clean, non-deprecated dependencies (no obsolete
mongodb-memory-serveror redundant type packages) - Initialises a clean git repository
Project structure
CEM generates an opinionated, domain-driven layout:
my-api/
├── src/
│ ├── app/
│ │ ├── config/index.ts # typed, centralized config & env validation
│ │ ├── config/swagger.ts # OpenAPI 3.0 spec generator (Swagger only)
│ │ ├── errors/ # AppError + DB error handler
│ │ ├── middlewares/ # auth, rate-limit, error, 404, compression
│ │ ├── modules/ # feature modules (auto-wired)
│ │ │ └── Auth/
│ │ ├── routes/index.ts # router registry
│ │ └── utils/ # catchAsync, sendResponse, QueryBuilder...
│ ├── app.ts # Express 5 app with compression
│ └── server.ts # Connection pooling + keep-alive listen
├── .env / .env.example
├── cem-cli.json # CEM manifest (tracks stack & features)
├── cem-cli.schema.json # Schema for editor IntelliSense & validation
├── Dockerfile / docker-compose.yml
├── eslint.config.js # ESLint v10 flat config
└── package.jsonRun it
bash
cd my-api
npm install
cem devOpen http://localhost:5000 — you'll see CEM's branded welcome page with live metadata, a clickable health check, and a link to the interactive Swagger docs at /docs.