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 folder structure
- Generates DB config, error handling, the
cem-cli.jsonmanifest,.env, and.env.example - Runs a single-pass ultra-fast dependency install (pre-populated version pins)
- Initialises a git repository
Project structure
CEM generates an opinionated, domain-driven layout:
my-api/
├── src/
│ ├── app/
│ │ ├── config/index.ts # typed, centralized config
│ │ ├── config/swagger.ts # OpenAPI 3.0 spec generator (Swagger only)
│ │ ├── errors/ # AppError + Mongoose handler
│ │ ├── middlewares/ # auth, rate-limit, error, 404
│ │ ├── modules/ # feature modules (auto-wired)
│ │ │ └── Auth/
│ │ ├── routes/index.ts # router registry
│ │ └── utils/ # catchAsync, sendResponse, QueryBuilder...
│ ├── app.ts # Express app
│ └── server.ts # DB + listen
├── .env / .env.example
├── cem-cli.json # CEM manifest (tracks stack & features)
├── Dockerfile / docker-compose.yml
└── 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.