projx / express
CLAUDE.md71 starsChanged 4 months agoMITView on GitHub
Stack-scoped notes. The root ../CLAUDE.md carries cross-cutting standards — read both, they compose. This directory is a projx template: a working backend whose own suite must stay green on the projx repo (root §"Per-template gates") and the source the CLI copies into scaffolded projects. It mirrors fastify/ feature-for-feature with Express idioms — keep the two in sync when changing the shared _base machinery. buildApp() in src/app.ts (verified): errorHandler + notFoundHandler register last (Express requires error middleware last). New middleware slots…
In this repository15 other files it gives its agents.
- admin-panel/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- cli/CLAUDE.mdCLAUDE.md
- e2e/CLAUDE.mdCLAUDE.md
- fastapi/CLAUDE.mdCLAUDE.md
- fastify/CLAUDE.mdCLAUDE.md
- go/CLAUDE.mdCLAUDE.md
- infra/CLAUDE.mdCLAUDE.md
- laravel/CLAUDE.mdCLAUDE.md
- mobile/CLAUDE.mdCLAUDE.md
- nextjs/CLAUDE.mdCLAUDE.md
- rust/CLAUDE.mdCLAUDE.md
- scripts/CLAUDE.mdCLAUDE.md
- vitejs/CLAUDE.mdCLAUDE.md
- projxSkill
The file
Files
express — Express / TypeScript backend (projx template)
Stack-scoped notes. The root
../CLAUDE.mdcarries cross-cutting standards — read both, they compose.This directory is a projx template: a working backend whose own suite must stay green on the projx repo (root §"Per-template gates") and the source the CLI copies into scaffolded projects. It mirrors
fastify/feature-for-feature with Express idioms — keep the two in sync when changing the shared_basemachinery.
Stack
- Runtime — Node (ESM),
tsxdev,tscbuild - Framework — Express 5
- Validation —
zod - ORM / DB — Prisma + Postgres (default ORM; alternates via
addons/orms/<orm>/) - Auth — JWT via
jose+jsonwebtoken(src/lib/jwt-verifier.ts,src/middlewares/authenticate.ts) - Package manager — pnpm 11 (per-project overrides / security pins + build-script approvals live in
pnpm-workspace.yaml, not the package.jsonpnpmfield — pnpm 11 stopped reading it) - Test — Vitest +
supertestagainst real Postgres (tests/global-setup.ts), v8 coverage - Logging —
pino-http,request_idcorrelation
Layout
| Path | What it holds |
src/server.ts | Entry: build app, listen |
src/app.ts | buildApp(options) — middleware chain (below) |
src/config.ts | Env loading + allowedOrigins() (bootstrap-only) |
src/errors.ts | ApiError, errorHandler, notFoundHandler |
src/prisma.ts | Prisma client + PrismaLike type |
src/lib/ | crypto.ts, jwt-verifier.ts, prisma-client.ts, service-config.ts |
src/middlewares/ | authenticate.ts, authz.ts |
src/modules/_base/ | entity-registry.ts, auto-routes.ts, query-engine.ts, repository.ts, service.ts, expand.ts, index.ts |
src/modules/audit-logs/ | Audit-log module |
prisma/schema.prisma | ServiceConfig + AuditLog + // projx-anchor: models |
tests/ | global-setup.ts, helpers/, lib/, middlewares/, modules/ |
Middleware chain — order matters, error handler last
buildApp() in src/app.ts (verified):
requestId → pinoHttp → helmet → cors → compression →
express.json/urlencoded (1mb) → rateLimit → authenticate →
[// projx-anchor: plugins] → GET /api/health →
entity routes (registerEntityRoutes per EntityRegistry) →
notFoundHandler → errorHandlererrorHandler + notFoundHandler register last (Express requires error middleware last). New middleware slots at the plugins anchor.
Error shape — { detail, request_id }
src/errors.ts errorHandler emits { detail, request_id } where request_id = res.locals.requestId (set by the requestId middleware). Never res.status(n).json({ detail }) outside the handler — you'll drop request_id.
EntityRegistry + lifecycle hooks
Same contract as fastify/: modules self-register; registerEntityRoutes mounts CRUD (pagination, equality filter, ILIKE search, order_by - desc, bulk). Hooks beforeCreate / afterCreate / beforeUpdate / afterUpdate / beforeDelete + beforeCreateFields[] (coverage-checked). Contract documented once in root §"Entity lifecycle hooks" — adapter types are Request/Response here.
DB-backed config / rate-limits / anchors
- Runtime creds in the encrypted
service_configstable viasrc/lib/service-config.ts— env is bootstrap-only. express-rate-limitis global defense-in-depth; IP-keyed limits belong at the nginx edge, not per-route.- Anchors:
src/app.ts// projx-anchor: imports+// projx-anchor: plugins;prisma/schema.prisma// projx-anchor: models.
Migrations
Ships schema.prisma only — prisma/migrations/ carries just migration_lock.toml. Users generate the first migration on setup. Never pre-bake migrations.
Quality gates (root §"Per-template gates")
pnpm format → pnpm lint → pnpm typecheck → pnpm test (vitest + supertest, real Postgres, v8 ≥80%). Green or not done; no src/ excludes, no it.skip.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

