# servergen

> CLI that scaffolds production-ready Node.js, Express, and Hono apps with practical defaults, optional views, MongoDB, Postgres, Prisma, OpenAPI, and Docker support.

Latest version **2.5.0** (published 2026-06-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install servergen
pnpm add servergen
yarn add servergen
bun add servergen
```

Provides the command `servergen`.

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.5.0 |
| Published | 2026-06-27 |
| First published | 2021-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 3 |
| Unpacked size | 110.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3 |
| Author | Keshav Malik |
| Maintainers | th3inf0s3cguy |
| Keywords | api, backend, boilerplate, cli, docker, express, generator, hono, mongodb, mvc, nodejs, postgres, postgresql, prisma, scaffold, scaffolding |

## Links

- npm: https://www.npmjs.com/package/servergen
- Repository: https://github.com/theinfosecguy/ServerGen
- Homepage: https://github.com/theinfosecguy/ServerGen#readme
- Issues: https://github.com/theinfosecguy/ServerGen/issues
- npm.io page: https://npm.io/package/servergen

## Dependencies (3)

- [chalk](https://npm.io/package/chalk.md) ^5.6.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.5
- [commander](https://npm.io/package/commander.md) ^14.0.2

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 2.5.0 (latest) — 2026-06-27
- 2.3.0 — 2026-06-24
- 2.2.3 — 2026-06-23
- 2.2.2 — 2026-06-21
- 2.2.1 — 2026-06-21
- 2.2.0 — 2026-06-21
- 2.1.0 — 2026-06-20
- 1.4.0 — 2026-06-14
- 1.3.0 — 2026-06-14
- 1.2.0 — 2022-04-04
- 1.0.1 — 2021-04-17
- 2.0.0 — 2021-03-12
- 1.0.0 — 2021-03-11

## README

# ServerGen

[![CI](https://github.com/theinfosecguy/ServerGen/actions/workflows/ci.yml/badge.svg)](https://github.com/theinfosecguy/ServerGen/actions/workflows/ci.yml)
[![npm version](https://img.shields.io/npm/v/servergen.svg)](https://www.npmjs.com/package/servergen)
[![npm downloads](https://img.shields.io/npm/dm/servergen.svg)](https://www.npmjs.com/package/servergen)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Node >=20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](package.json)
[![GitHub release](https://img.shields.io/github/v/release/theinfosecguy/ServerGen?display_name=tag)](https://github.com/theinfosecguy/ServerGen/releases/latest)

ServerGen is an npm CLI for scaffolding Node.js, Express, and Hono API projects
with practical defaults: MVC-style folders, health checks, Docker files,
ready-to-run npm scripts, optional Express views, and optional
Mongoose/MongoDB or Postgres/Prisma config.

## 30-Second Quick Start

Requires Node.js 20 or higher.

```bash
npm create servergen@latest
cd my-api
npm start
```

In another terminal:

```bash
curl http://localhost:3000/health
```

Expected response:

```json
{"status":"ok"}
```

The create flow guides you through the app name and options interactively,
creates an Express app by default, and runs `npm install` in the generated app
unless install is skipped.

Prefer the direct CLI path when you already know the app name and options:

```bash
npx servergen@latest my-api
```

## What Gets Generated

| Choice | Output |
| --- | --- |
| Default Express app | `index.js`, `routes/index.js`, `controllers/`, `model/`, `views/`, `.env.example`, `Dockerfile`, `.dockerignore`, `.gitignore`, generated `README.md`, `package.json`, and `test/app.test.js`. |
| `--typescript` | TypeScript Express app with `src/index.ts`, `src/routes/index.ts`, `tsconfig.json`, `test/app.test.ts`, `tsx` for development, and `dist/` output for production start. Hono apps are TypeScript by default. |
| `--framework node` | Plain Node.js HTTP server with `/`, `/about`, `/contact`, and `/health`, plus MVC folders, Docker files, `.gitignore`, generated `README.md`, and `package.json`. |
| `--framework hono` | TypeScript Hono API app with `src/index.ts`, `tsconfig.json`, `test/app.test.ts`, Docker files, `.gitignore`, generated `README.md`, and `package.json`. |
| `--view ejs`, `pug`, or `hbs` | Adds the selected Express view template and renders it from `/`. |
| `--db mongodb` | Adds Mongoose, `config/mongoose.js`, and `MONGODB_URI` in `.env.example` for Express apps. |
| `--typescript --db postgres --orm prisma` | Adds Prisma 7, a Postgres Docker Compose service, `prisma/schema.prisma`, `prisma.config.ts`, `src/lib/prisma.ts`, `/users` routes/controllers, generated route tests, and `DATABASE_URL` in `.env.example` for Express TypeScript apps. |
| `--openapi` | Adds `docs/openapi.yaml`, a static OpenAPI 3.0 spec for generated Express and Hono routes. Postgres/Prisma apps include `/users` paths. |

Generated apps include `npm start` and `npm run dev`. Express apps also include
`npm test`. TypeScript Express and Hono apps also include `npm run build`.

## CLI Usage

```bash
servergen [options] [name]
```

`name` is the app directory to create. You can also pass it with `--name`.

### Options

```text
  -V, --version           output the version number
  -n, --name <name>       name of the app to create
  -f, --framework <type>  framework: express | node | hono (default: "express")
  -v, --view <type>       view engine (express only): ejs | pug | hbs
  --db <type>             database: mongodb | postgres
  --orm <type>            ORM for supported databases: prisma
  --openapi               generate an OpenAPI spec file (express and hono)
  --typescript            generate a TypeScript app where supported
  -p, --port <number>     port for the generated app (1-65535) (default: "3000")
  --skip-install          skip the npm install step
  --debug                 enable debug logging
  -h, --help              display help for command
```

### Examples

```bash
npm create servergen@latest
npx servergen@latest my-api
npx servergen@latest my-api --framework node
npx servergen@latest my-api --framework hono
npx servergen@latest my-api --view ejs
npx servergen@latest my-api --db mongodb
npx servergen@latest my-api --typescript --db postgres --orm prisma
npx servergen@latest my-api --openapi
npx servergen@latest my-api --typescript
npx servergen@latest my-api --port 8080
npx servergen@latest my-api --skip-install
npx servergen@latest --name my-api
```

For command-by-command walkthroughs, generated file lists, and verification
steps, see the [scaffold examples](https://github.com/theinfosecguy/ServerGen/tree/main/docs/examples).

## Install Options

Use the interactive create flow for the shortest first run:

```bash
npm create servergen@latest
```

Use `npx` when you want the direct CLI path without adding ServerGen to another
project:

```bash
npx servergen@latest my-api
```

Install locally when you want ServerGen pinned in a project:

```bash
npm install --save-dev servergen
npx servergen my-api
```

For local installs, `servergen` is installed under `node_modules/.bin` and is
not available as a plain shell command unless your shell PATH includes local npm
bins.

Install globally when you want the `servergen` command available everywhere:

```bash
npm install -g servergen
servergen my-api
```

## Release Integrity

Tagged releases are published from GitHub Actions with npm trusted publishing
and provenance, using OIDC instead of a long-lived npm token. Before publishing,
the release workflow packs the package, installs that tarball in a throwaway
project, scaffolds Express, Hono, and Node apps, starts them, and verifies live HTTP
responses.

The same workflow creates or updates the matching GitHub Release as `latest`
after npm publish succeeds, so GitHub releases track the npm `latest` package.

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/servergen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
