Skip to content

feat: add typed route generator for Hono (generateRoutes v2) #17

Description

@stackbilt-admin

Problem

generateRoutes currently emits handler bodies as plain strings, requiring manual paste or eval at the consumer site. This is incompatible with typed Cloudflare Workers frameworks.

FoodFiles uses Hono with a typed app environment (Hono<AppEnv>). String-emitted handlers:

  • Cannot be type-checked by tsc
  • Cannot be composed with AppEnv generics (bindings, variables)
  • Cannot be tree-shaken or statically analyzed by bundlers

This blocks any automated route wiring for phase-0 consumers and makes generateRoutes unusable in a typed Hono project.

Acceptance Criteria

  • generateRoutes returns importable route handler functions (or a Hono router instance) instead of strings
  • Output is parameterized by an Env generic so consumers can pass Hono<AppEnv> context through
  • Generated handlers preserve the full input/output types derived from the contract schema
  • A toHonoRouter<Env>(contract, handlers) helper (or equivalent) is exported from the package
  • At least one generated route passes tsc --strict in an isolated test fixture
  • Existing generateRoutes string-output API is deprecated with a migration note in the changelog

Context

FoodFiles is the designated phase-0 consumer for @stackbilt/contracts. The pantry and recipe routes are the primary integration targets. Without typed route generation, the contract layer cannot replace the hand-rolled Zod schemas in services/pantry.ts and services/recipe.ts.

Ref: CONTRACT-1 gap analysis (phase-0 integration audit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions