Skip to content

feat: CLI flags, feature generator, validation, OpenAPI docs, Docker and Drizzle - #20

Merged
Be1newinner merged 1 commit into
mainfrom
feat/flags-generator-validation-openapi-docker-drizzle
Oct 26, 2026
Merged

Be1newinner merged 1 commit into
mainfrom
feat/flags-generator-validation-openapi-docker-drizzle

Conversation

@Be1newinner

Copy link
Copy Markdown
Owner

Summary

Six features:

  1. CLI flags: --db, --pm, --install/--no-install, --git/--no-git. Any flag skips its prompt, and --yes fills in the rest. The default package manager is the one that launched the CLI.
  2. Feature generator: npm run gen:feature -- order creates schema, model, service, controller, route and test files, and mounts the router at /api/v1/orders.
  3. validate({ body, query, params }) middleware: returns a 400 listing every failing field. DTO types are derived from the Zod schemas.
  4. OpenAPI docs: generated from the same schemas. Swagger UI at /docs, raw spec at /docs/openapi.json. Off by default in production; API_DOCS_ENABLED overrides.
  5. Docker: multi-stage Dockerfile (non-root, healthcheck) adapted to npm/pnpm/yarn/bun, and a docker-compose.yml matched to the database.
  6. Drizzle: new PostgreSQL + Drizzle database option.

Changes these needed:

  • Templates ship inside the npm package instead of being downloaded from main. Each database is an overlay folder (packages/overlays/*) copied over the base template, which replaces the regex marker patching.
  • src/app.ts is split from index.ts and the template now has 17 real tests (npm test used to fail with "No test files found").
  • Malformed JSON and oversized bodies now return 400/413 instead of 500.
  • Lockfiles are committed (no longer gitignored). This fixes the failing CI and is required for Docker builds.
  • pnpm 10/11: dependency build scripts are pre-approved (bcrypt, esbuild, Prisma). pnpm 11 otherwise fails the install.
  • mongo:8.2 is pinned: mongo:8 refuses to start on Linux kernel 6.19+.
  • CI runs template checks on Node 20/22/24, then scaffolds every database variant (plus pnpm + Prisma) and type-checks, lints, tests and Docker-builds each one.
  • Node >=20 is now required. The unused ora/yauzl dependencies are dropped.

Test plan

Verified locally:

  • All four database variants scaffold and pass check, lint, build and test, both with and without a generated feature
  • Scaffolding from a packed tarball works (50 kB, 67 files)
  • docker compose up for the Prisma, Drizzle and Mongoose variants reports "db":"connected" on /health; the no-database image is healthy and runs as node
  • pnpm 10, pnpm 11 and yarn 1 scaffold and pass; pnpm + Prisma also runs in Docker
  • Swagger UI assets load under Helmet's CSP
  • bun: not tested (not installed locally)
  • The new CI workflow, on its first GitHub run

Before publishing

The published v3.0.0 CLI downloads the template from main. After this merges, projects it creates won't get the database wiring (otherwise they still work). Publish a new version right after merging; 4.0.0 is suggested because the template layout changed. The version isn't bumped in this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pLhuJbdhCyvDro7o6h1wp

…and Drizzle

- CLI: --db, --pm, --install/--no-install, --git/--no-git flags (any flag
  skips its prompt; --yes fills in the rest); default package manager is
  the one that launched the CLI
- Templates now ship inside the npm package instead of being downloaded
  from main; databases are overlay folders copied over the base template
- Template: validate({ body, query, params }) middleware returning every
  failing field; DTO types derived from Zod schemas
- Template: OpenAPI 3 docs generated from the same schemas, Swagger UI at
  /docs (off by default in production, API_DOCS_ENABLED overrides)
- Template: npm run gen:feature -- <name> scaffolds a CRUD module, its
  docs and tests, and mounts the router
- Template: multi-stage Dockerfile (non-root, healthcheck) adapted to the
  chosen package manager, docker-compose.yml matched to the database
- New database option: PostgreSQL + Drizzle
- Template: split app.ts from index.ts, add Vitest + Supertest tests
- Fix malformed JSON / oversized bodies returning 500 instead of 400/413
- Commit lockfiles (no longer gitignored); pre-approve build scripts for
  pnpm 10/11; pin mongo:8.2 (mongo:8 fails on Linux kernel 6.19+)
- CI: template checks on Node 20/22/24, then scaffold, test and
  docker-build every database variant
- Require Node >=20; drop unused ora/yauzl dependencies

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015pLhuJbdhCyvDro7o6h1wp
@Be1newinner
Be1newinner merged commit e516aec into main Oct 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant