Skip to content

TsRestApi and route registration

View as Markdown

initContract and TsRestApi exported from @sapporta/server.

  • initContract() creates ts-rest query and mutation contracts.
  • new TsRestApi<Env>() creates a Hono-compatible contract registry.
  • register(routeId, route, handler) supplies parsed request and Hono context c.
  • Handlers return a response declared by the route as { status, body } or a supported raw response.
  • Project route modules are mounted explicitly from loadApp(); mounting under /api adds the public prefix.
import { initContract, TsRestApi } from "@sapporta/server";