You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codegen-ts: routesFileHono cannot emit expose, so its output mounts all five CRUD verbs #348
The generated per-entity Hono wrapper calls mountCrudRoutes with no expose option, so it mounts all five CRUD verbs. expose exists on mountCrudRoutes itself, but there is no way to reach it from the generated wrapper — not through metadata, not through a generator option.
Any consumer whose tables are written through narrow, audited paths rather than generic CRUD therefore cannot use the generated routes at all.
Why this is more than an ergonomics gap
In one TypeScript/Hono consumer, mounting the generated wrappers was verified to allow a bearer-token holder to:
PATCH a decision row to rewrite its stored presented text and flip its status
POST a row that bypassed the paired audit-log write the application otherwise guarantees
DELETE a row, defeating a double-decision guard by enabling a re-decide
That consumer ended up hand-writing ten mountCrudRoutes({ ..., expose: ["list", "get"] }) calls — while ten generated routes files sat next to the entities, imported by nothing, each carrying the doc comment:
Customize: register this as-is for stock CRUD, ...
A later reader doing dead-code cleanup is therefore actively invited to adopt the one thing that must not be adopted. That is what happened: an adoption audit listed those files as dead weight to adopt.
Ask
An expose passthrough on the generated wrapper. Any of:
a generator option — routesFileHono({ expose: (entity) => [...] })
a metadata attribute the generator reads (see the sibling issue about @emitRoutes not being registerable — same shape)
emitting it as an optional third parameter of the generated register<Entity>Routes(app, deps, opts)
(1) is the smallest change and composes with the existing filter option.
Workaround
Copy src/reference/routes-hono.ts into the project, stop calling renderRoutesFileHono, and render the CRUD body locally so expose can be emitted. This is what scaffold-and-own is for and it works — but it forks the renderer, so upstream template improvements have to be merged by hand. Projections still delegate to renderRoutesFileHono, since mountReadOnlyCrudRoutes is read-only already.
Confirmed, and broader than filed — leaving this open.
The Hono wrapper is not the only one. expose exists on all three mount helpers (runtime-ts/src/fastify/index.ts:49, drizzle-fastify/index.ts:62, hono/index.ts:83, each new Set<CrudVerb>(opts.expose ?? ALL_VERBS)), but across the generated route emitters there is exactly one call site that passes it — templates/routes-file.ts:358, expose: ["list", "get"], on the read-only projection branch. For a vanilla or write-through entity, neither the Fastify nor the Hono emitter can restrict verbs. So the title should really say "the generated route files", not routesFileHono.
The use case is legitimate and is one we now name explicitly in the shipped agent context: a project whose tables are written through narrow, audited paths should not be mounting generic CRUD, and an emitted-but-unmounted routes file is worse than no file, because it still carries a doc comment saying to register it as-is for stock CRUD — inviting a later dead-code cleanup to adopt exactly the surface you decided against.
Two candidate answers, and the choice matters:
Own the generator. Under ADR-0034 the routes generator is yours — meta eject routes-hono puts it in your repo, and adding expose to the mountCrudRoutes call is a one-line edit to your own code. This works today with no release. What is missing is that the reference template's customize: header does not nameexpose as a swap point, so the move isn't discoverable from the file you're told to edit.
Note that a metadata attribute is deliberately not on that list — that is the shape #349 just retired.
Leaning toward (1) plus making it discoverable, with (2) if the ergonomics don't hold up. Input welcome on which fits your setup better, since you're the one running it.
Verbs or a per-entity function. Absent, or a function returning undefined, means all five and emits no expose key at all — so output is byte-identical for every project that doesn't use it. That's pinned as its own test rather than assumed.
Why an option rather than the filter remedy (the one that answered #349): filter decides whether the file emits at all, per entity, so it can only remove the whole surface. Restricting to a subset of verbs is a different axis, and filter structurally cannot express it. Same reasoning that made a TPH subtype's opt-IN grid tphSubtypeGrids rather than a filter.
Deliberately not a metadata attribute: which verbs a deployment exposes is a property of the app, not the model — the same entity is read-only in one service and writable in another, and an attribute would force one answer into the shared spine. That's the shape #349 just retired.
One behaviour worth knowing: a TPH polymorphic mount is read-only by construction (the discriminated union has no single writable shape), so exposeintersects with its fixed ["list","get"] rather than replacing it. You can narrow it to ["list"]; asking for create yields an empty set rather than a route that fails at runtime. Hono's projection branch is untouched — it calls mountReadOnlyCrudRoutes, a different helper with no writable surface to narrow.
The reference templates carry the option too, so an ejected generator behaves identically, and CRUD_VERBS / resolveExpose / intersectExpose / exposeLine are public so an owned routes generator can compose the same call.
One thing your report prompted that's worth naming: the verb union is restated in codegen-ts (it emits a call to the runtime helper, it never links against it), and nothing compared the two. That's the same drift class as #355. It's now gated against both runtime declarations.
Activity
dmealing commentedon Aug 31, 2026
Confirmed, and broader than filed — leaving this open.
The Hono wrapper is not the only one.
exposeexists on all three mount helpers (runtime-ts/src/fastify/index.ts:49,drizzle-fastify/index.ts:62,hono/index.ts:83, eachnew Set<CrudVerb>(opts.expose ?? ALL_VERBS)), but across the generated route emitters there is exactly one call site that passes it —templates/routes-file.ts:358,expose: ["list", "get"], on the read-only projection branch. For a vanilla or write-through entity, neither the Fastify nor the Hono emitter can restrict verbs. So the title should really say "the generated route files", notroutesFileHono.The use case is legitimate and is one we now name explicitly in the shipped agent context: a project whose tables are written through narrow, audited paths should not be mounting generic CRUD, and an emitted-but-unmounted routes file is worse than no file, because it still carries a doc comment saying to register it as-is for stock CRUD — inviting a later dead-code cleanup to adopt exactly the surface you decided against.
Two candidate answers, and the choice matters:
meta eject routes-honoputs it in your repo, and addingexposeto themountCrudRoutescall is a one-line edit to your own code. This works today with no release. What is missing is that the reference template'scustomize:header does not nameexposeas a swap point, so the move isn't discoverable from the file you're told to edit.@emitGridbecametphSubtypeGridsrather than metadata vocabulary (see codegen-ts:@emitRoutes(and emitGrid/emitForm/emitTanstack) are read by codegen but not registered, so they cannot be authored #349). This is what would suit a project that hasn't ejected.Note that a metadata attribute is deliberately not on that list — that is the shape #349 just retired.
Leaning toward (1) plus making it discoverable, with (2) if the ergonomics don't hold up. Input welcome on which fits your setup better, since you're the one running it.
dmealing commentedon Aug 31, 2026
Fixed on
main; ships in the next release. Shipped as a generator option on both emitters, not just Hono — the gap was wider than the title.Verbs or a per-entity function. Absent, or a function returning
undefined, means all five and emits noexposekey at all — so output is byte-identical for every project that doesn't use it. That's pinned as its own test rather than assumed.Why an option rather than the
filterremedy (the one that answered #349):filterdecides whether the file emits at all, per entity, so it can only remove the whole surface. Restricting to a subset of verbs is a different axis, andfilterstructurally cannot express it. Same reasoning that made a TPH subtype's opt-IN gridtphSubtypeGridsrather than a filter.Deliberately not a metadata attribute: which verbs a deployment exposes is a property of the app, not the model — the same entity is read-only in one service and writable in another, and an attribute would force one answer into the shared spine. That's the shape #349 just retired.
One behaviour worth knowing: a TPH polymorphic mount is read-only by construction (the discriminated union has no single writable shape), so
exposeintersects with its fixed["list","get"]rather than replacing it. You can narrow it to["list"]; asking forcreateyields an empty set rather than a route that fails at runtime. Hono's projection branch is untouched — it callsmountReadOnlyCrudRoutes, a different helper with no writable surface to narrow.The reference templates carry the option too, so an ejected generator behaves identically, and
CRUD_VERBS/resolveExpose/intersectExpose/exposeLineare public so an owned routes generator can compose the same call.One thing your report prompted that's worth naming: the verb union is restated in
codegen-ts(it emits a call to the runtime helper, it never links against it), and nothing compared the two. That's the same drift class as #355. It's now gated against both runtime declarations.feat(codegen-ts): a generated routes file can mount fewer than five C…
docs(changelog): the expose option on both routes generators
fix(codegen): generated files stop pointing at a plugin point that do…