generate-express-ts-api
v0.0.5
Published
Scaffold an Express + TypeScript API from the express-template boilerplate
Downloads
739
Maintainers
Readme
Generate Express TS API
Scaffold an Express + TypeScript API with one command.
- Creating an App – How to create a new API.
- Available Scripts – Commands inside a generated project.
- What’s Included? – Features and defaults.
Works on macOS, Windows, and Linux.
Quick Overview
npx generate-express-ts-api my-api
cd my-api
npm install
docker compose up -d
npm run db:migrate
npm run devThen open http://localhost:4000/api/v1.
(npx comes with npm 5.2+.)
Get Started Immediately
You don’t need to wire Express, TypeScript, an ORM, JWT, or Docker by hand. Sensible defaults are chosen for you so you can focus on your API.
Create a project, install dependencies, and you’re good to go.
Creating an App
You’ll need Node.js 18 or later on your local machine. We recommend the latest LTS. You can use nvm (macOS/Linux) or nvm-windows to switch Node versions between projects.
Docker is optional but recommended when using PostgreSQL or MySQL.
To create a new app, run:
npx
npx generate-express-ts-api my-apinpm
npm init generate-express-ts-api my-apinpm init <initializer> is available in npm 6+
Yarn
yarn create generate-express-ts-api my-apiIt will create a directory called my-api inside the current folder.
Inside that directory, it will generate the project structure (default: MikroORM + PostgreSQL + JWT + Docker).
With prompts skipped:
npx generate-express-ts-api my-api --yesCustomize during scaffold:
npx generate-express-ts-api my-api --yes --orm prisma --database mysql
npx generate-express-ts-api my-api --yes --orm typeorm --no-jwt --deploy none
npx generate-express-ts-api my-api --yes --deploy pm2
npx generate-express-ts-api my-api --yes --provider giget
npx generate-express-ts-api my-api --yes --package-manager pnpmOptions
| Option | Description | Default |
| -------------------------- | -------------------------------------------------- | ---------- |
| --yes, -y | Skip prompts and use defaults | off |
| --orm <name> | mikroorm | sequelize | prisma | typeorm | mikroorm |
| --database <type> | postgres | mysql | sqlite | postgres |
| --jwt / --no-jwt | Include JWT auth module | on |
| --deploy <mode> | docker | pm2 | none | docker |
| --docker / --no-docker | Alias for --deploy docker / --deploy none | — |
| --pm2 | Alias for --deploy pm2 | — |
| --redis / --no-redis | Include Redis + Socket.IO deps | off |
| --git / --no-git | Initialize a git repository | on |
| --package-manager <pm> | npm | pnpm | yarn | bun | npm |
| -h, --help | Show help | |
A typical generated project looks like this (MikroORM default):
my-api
├── README.md
├── package.json
├── tsconfig.json
├── docker-compose.yml
├── Dockerfile
├── mikro-orm.config.ts
├── .env
├── .env.example
└── src
├── index.ts
├── bootstrap/
│ ├── app.ts
│ ├── index.ts
│ └── routes.ts
├── config/
├── infrastructure/
│ ├── auth/
│ ├── database/
│ │ ├── entities/
│ │ └── migrations/
│ └── socket.ts
├── modules/
│ ├── auth/
│ └── users/
├── scripts/
├── shared/
│ ├── errors/
│ ├── middlewares/
│ └── types/
└── tests/The template keeps bootstrapping, domain modules, infrastructure adapters, and shared utilities separate so the project can grow without moving files around immediately. Once generation is done:
cd my-api
npm installInside the newly created project, you can run the built-in commands below.
Package Manager Notes
Generated projects include Express 5 type overrides so express-validation does not pull incompatible Express 4 types:
- npm uses
overridesinpackage.json - Yarn uses
resolutionsinpackage.json - pnpm 11+ uses
overridesinpnpm-workspace.yaml
When using --provider giget, the CLI downloads the GitHub repository directly and skips the giget template registry.
Available Scripts
In the project directory, you can run:
npm run dev
Runs database migrations, then starts the API in development mode with Nodemon. Open http://localhost:4000/api/v1.
The server reloads when you change source files.
Tip:
DEBUG=express:*is enabled in the defaultdevscript, so Express may print verbose router logs. Removeexpress:*frompackage.jsonif you want quieter output.
npm run db:migrate
Applies pending ORM migrations.
If Docker was included, start the database first:
docker compose up -dnpm run migration:generate
Creates a new migration (ORM-specific CLI under the hood).
npm run build
Compiles TypeScript to the dist folder.
npm start
Runs the compiled production build from dist. If the app was generated with --deploy pm2, the generated start command uses PM2 runtime.
npm run lint
Runs ESLint on src.
Philosophy
- One command: Bootstrap a production-shaped Express API without assembling packages by hand.
- Sensible defaults: MikroORM + PostgreSQL + JWT + Docker work out of the box; flip flags when you need something else.
- No lock-in to one ORM: Choose MikroORM, Sequelize, Prisma, or TypeORM at scaffold time.
- Own your code: Generated projects are plain Node/TypeScript — edit anything; there is no hidden runtime beyond normal dependencies.
What’s Included?
Your environment will have everything you need to build a modern Express API:
- Express 5 + TypeScript
- MikroORM by default (or Sequelize / Prisma / TypeORM)
- PostgreSQL, MySQL, or SQLite
- Optional JWT auth (Passport + bcrypt)
- Optional production runtime: Docker (Dockerfile) or PM2
- Optional Docker Compose for DB/Redis
- Optional Redis + Socket.IO
- Migrations wired to
npm run db:migrate - Winston / express-winston logging
- ESLint + Prettier baseline
The tradeoff is that these tools are preconfigured to work together. You can change any of it after scaffold — it’s your project.
Contributing
Issues and PRs are welcome in the generate-express-ts-api repository.
Releasing
- Bump
versioninpackages/generate-express-ts-api/package.json. - Commit the change.
- Tag and push:
git tag v0.0.5
git push origin v0.0.5The Release workflow will:
- smoke-test the CLI
- publish
generate-express-ts-apito npm - create a GitHub Release with notes
Requires NPM_TOKEN (or npm Trusted Publishing configured for workflow file release.yml).
License
MIT
