seanpmaxwell/express-generator-typescript

CLI that generates a production-ready Express + TypeScript project — strict tsconfig, ESLint, Vitest, and a working CRUD example baked in.

TypeScript

945

350 commits

updated Oct 11, 2026

See the code

See what people are saying

SourceMessageScoreDate

I updated express-generator-typescript to use zod for middleware validation (r/webdev)

I've known about Zod, a JavaScript/TypeScript schema validation library, for a while, but I underestimated the size of its ecosystem. After using it for some form validation in React, I thought I'd see how well it integrated with Express. Sure enough, there were several middleware libraries for Zod…

4

Oct 10, 2026

README

express-generator-typescript

express-generator-typescript

npm version npm downloads License

A command-line tool that generates production-ready Express projects with TypeScript built in. Spin up a web server in seconds that follows the TypeScript best practices.

· · ·

🧭 Overview

express-generator-typescript works like the classic express-generator package, but the project it creates is fully set up for TypeScript. You get strict typing, linting, hot reloading, and testing, with defaults aimed at APIs and no build step. The project is an ES module and comes with a #src/* import alias, so imports stay clean as the app grows.

· · ·

✨ Features

  • TypeScript-first – strict compiler settings, linting, and sensible tsconfig defaults, ready to go.
  • Built for APIs – ideal for SPAs, mobile backends, or services.
  • Fast development – runs TypeScript directly with Node's built-in type stripping (no build step, in development or production), restarts the server when you change it, and refreshes the browser when you change front-end files. Node's built-in test runner and ESLint are included.
  • Path aliases – import from #src/* anywhere. It works in development, tests, and production.
  • Lean dependencies – no view engine, ORM, or UI layer; only the essentials for Express + TypeScript.

· · ·

📦 Installation

Requires Node.js 22.18+ (22.x), 24.x, or 26+.

npx express-generator-typescript
# or install globally
npm install -g express-generator-typescript

· · ·

⚡ Quick Start

# generate a project (defaults to express-gen-ts)
npx express-generator-typescript my-api

cd my-api

# start developing at http://localhost:3000
npm run dev

· · ·

🖥️ CLI Options

OptionDescription
project nameFolder to create. Defaults to express-gen-ts.
--use-yarnInstall dependencies with Yarn instead of npm.
--forceWrite into a folder that isn't empty. Files with the same name are overwritten.
-h, --helpShow usage.
-v, --versionShow the generator version.

Without --force, the generator won't write into a folder that already has files in it, so it can't overwrite your work by accident.

· · ·

🧩 Generated Template

The generated project is a small CRUD app for a User record. It shows how to structure models, services, and routes in Express + TypeScript. Linting, formatting, testing, and hot reloading are all set up for you.


Available package.json scripts

  • npm run dev – Run the server in development with live reload and browser refresh.
  • npm test – Run the tests with Node's built-in test runner.
  • npm test -- tests/users.test.ts – Run a single test file.
  • npm run lint – Check the code with ESLint.
  • npm run format – Format the code with Prettier.
  • npm start – Run the server in production mode (no build step).
  • npm run typecheck – Check for TypeScript errors.
  • npm run install:clean – Delete node_modules and the lockfile, then reinstall.

Architecture

The app uses a layered architecture, which suits a small CRUD app. If you plan to grow it, consider switching to a domain-based layout. The Typescript Best Practices README explains both patterns.

Layers explained:

- config/         → .env files for each environment
- src/            → Source code
  - common/       → Shared code
    - classes/    → Shared classes (e.g. route errors)
    - constants/
      - Paths.ts  → Single source of truth for all API routes
    - types/      → Shared types
    - utils/      → Shared helper functions
  - entities/     → Describe and handle database records (one folder per entity)
  - routes/       → Read and validate values from Express requests; send responses
  - services/     → Business logic (where everything comes together)
  - repos/        → Talk to the database
  - public/       → Front-end scripts and styles
  - views/        → HTML pages
  - main.ts       → Starts the server
  - server.ts     → Sets up the Express app
- tests/          → Tests

· · ·

Notes for VS Code users

Format on save

The generated project uses ESLint for linting and Prettier for formatting. To format on save, install the Prettier extension for VS Code and set it as the default formatter in .vscode/settings.json:

// .vscode/settings.json
{
  "editor.minimap.enabled": false,
  "editor.rulers": [80],
  "editor.tabSize": 2,

  "workbench.sideBar.location": "right",
  "workbench.editor.empty.hint": "hidden",

  // Formatting: Prettier only
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",

  // ESLint: linting only (NO formatting)
  "eslint.format.enable": false,
  "eslint.nodePath": "node_modules",
  "eslint.validate": ["javascript", "typescript", "typescriptreact"],

  // Run ESLint fixes (non-formatting) on save
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },

  // Language overrides (keep Prettier)
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

  // JSDoc noise reduction
  "javascript.suggest.completeJSDocs": false,
  "javascript.suggest.jsdoc.generateReturns": false,
  "typescript.suggest.completeJSDocs": false,
  "typescript.suggest.jsdoc.generateReturns": false
}
Debugging

To debug with breakpoints in VS Code, start the app or tests from .vscode/launch.json:

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Dev",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "npm",
      "runtimeArgs": ["run", "dev"],
      "skipFiles": ["<node_internals>/**"],
      "console": "integratedTerminal"
    },
    {
      "name": "Test",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "npm",
      "runtimeArgs": ["run", "test"],
      "skipFiles": ["<node_internals>/**"],
      "console": "integratedTerminal"
    }
  ]
}

· · ·

📄 License

MIT © seanpmaxwell1

boilerplate
cli
eslint
express
express5
expressjs
generator
nodejs
rest-api
scaffolding
starter-kit
typescript
vitest

seanpmaxwell/express-generator-typescript

CLI that generates a production-ready Express + TypeScript project — strict tsconfig, ESLint, Vitest, and a working CRUD example baked in.

TypeScript

945

350 commits

updated Oct 11, 2026

See the code

See what people are saying

SourceMessageScoreDate

I updated express-generator-typescript to use zod for middleware validation (r/webdev)

I've known about Zod, a JavaScript/TypeScript schema validation library, for a while, but I underestimated the size of its ecosystem. After using it for some form validation in React, I thought I'd see how well it integrated with Express. Sure enough, there were several middleware libraries for Zod…

4

Oct 10, 2026

README

express-generator-typescript

express-generator-typescript

npm version npm downloads License

A command-line tool that generates production-ready Express projects with TypeScript built in. Spin up a web server in seconds that follows the TypeScript best practices.

· · ·

🧭 Overview

express-generator-typescript works like the classic express-generator package, but the project it creates is fully set up for TypeScript. You get strict typing, linting, hot reloading, and testing, with defaults aimed at APIs and no build step. The project is an ES module and comes with a #src/* import alias, so imports stay clean as the app grows.

· · ·

✨ Features

  • TypeScript-first – strict compiler settings, linting, and sensible tsconfig defaults, ready to go.
  • Built for APIs – ideal for SPAs, mobile backends, or services.
  • Fast development – runs TypeScript directly with Node's built-in type stripping (no build step, in development or production), restarts the server when you change it, and refreshes the browser when you change front-end files. Node's built-in test runner and ESLint are included.
  • Path aliases – import from #src/* anywhere. It works in development, tests, and production.
  • Lean dependencies – no view engine, ORM, or UI layer; only the essentials for Express + TypeScript.

· · ·

📦 Installation

Requires Node.js 22.18+ (22.x), 24.x, or 26+.

npx express-generator-typescript
# or install globally
npm install -g express-generator-typescript

· · ·

⚡ Quick Start

# generate a project (defaults to express-gen-ts)
npx express-generator-typescript my-api

cd my-api

# start developing at http://localhost:3000
npm run dev

· · ·

🖥️ CLI Options

OptionDescription
project nameFolder to create. Defaults to express-gen-ts.
--use-yarnInstall dependencies with Yarn instead of npm.
--forceWrite into a folder that isn't empty. Files with the same name are overwritten.
-h, --helpShow usage.
-v, --versionShow the generator version.

Without --force, the generator won't write into a folder that already has files in it, so it can't overwrite your work by accident.

· · ·

🧩 Generated Template

The generated project is a small CRUD app for a User record. It shows how to structure models, services, and routes in Express + TypeScript. Linting, formatting, testing, and hot reloading are all set up for you.


Available package.json scripts

  • npm run dev – Run the server in development with live reload and browser refresh.
  • npm test – Run the tests with Node's built-in test runner.
  • npm test -- tests/users.test.ts – Run a single test file.
  • npm run lint – Check the code with ESLint.
  • npm run format – Format the code with Prettier.
  • npm start – Run the server in production mode (no build step).
  • npm run typecheck – Check for TypeScript errors.
  • npm run install:clean – Delete node_modules and the lockfile, then reinstall.

Architecture

The app uses a layered architecture, which suits a small CRUD app. If you plan to grow it, consider switching to a domain-based layout. The Typescript Best Practices README explains both patterns.

Layers explained:

- config/         → .env files for each environment
- src/            → Source code
  - common/       → Shared code
    - classes/    → Shared classes (e.g. route errors)
    - constants/
      - Paths.ts  → Single source of truth for all API routes
    - types/      → Shared types
    - utils/      → Shared helper functions
  - entities/     → Describe and handle database records (one folder per entity)
  - routes/       → Read and validate values from Express requests; send responses
  - services/     → Business logic (where everything comes together)
  - repos/        → Talk to the database
  - public/       → Front-end scripts and styles
  - views/        → HTML pages
  - main.ts       → Starts the server
  - server.ts     → Sets up the Express app
- tests/          → Tests

· · ·

Notes for VS Code users

Format on save

The generated project uses ESLint for linting and Prettier for formatting. To format on save, install the Prettier extension for VS Code and set it as the default formatter in .vscode/settings.json:

// .vscode/settings.json
{
  "editor.minimap.enabled": false,
  "editor.rulers": [80],
  "editor.tabSize": 2,

  "workbench.sideBar.location": "right",
  "workbench.editor.empty.hint": "hidden",

  // Formatting: Prettier only
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",

  // ESLint: linting only (NO formatting)
  "eslint.format.enable": false,
  "eslint.nodePath": "node_modules",
  "eslint.validate": ["javascript", "typescript", "typescriptreact"],

  // Run ESLint fixes (non-formatting) on save
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  },

  // Language overrides (keep Prettier)
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

  // JSDoc noise reduction
  "javascript.suggest.completeJSDocs": false,
  "javascript.suggest.jsdoc.generateReturns": false,
  "typescript.suggest.completeJSDocs": false,
  "typescript.suggest.jsdoc.generateReturns": false
}
Debugging

To debug with breakpoints in VS Code, start the app or tests from .vscode/launch.json:

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Dev",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "npm",
      "runtimeArgs": ["run", "dev"],
      "skipFiles": ["<node_internals>/**"],
      "console": "integratedTerminal"
    },
    {
      "name": "Test",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "npm",
      "runtimeArgs": ["run", "test"],
      "skipFiles": ["<node_internals>/**"],
      "console": "integratedTerminal"
    }
  ]
}

· · ·

📄 License

MIT © seanpmaxwell1

boilerplate
cli
eslint
express
express5
expressjs
generator
nodejs
rest-api
scaffolding
starter-kit
typescript
vitest

Project health

Overall

4.0/10

Maintained

10/10

Code review

0/10
OpenSSF Scorecard

Latest release

3.2.0 · Oct 11, 2026

Releases this year

24

Significant stargazers

yhirano55

443 followers · starred Jul 2021

William Grosset

54 followers · starred May 2020

cheongjin kim (김청진)

175 followers · starred May 2020