httpContract
function httpContract<T extends Record<string, RequestDescriptor>>(descriptor: T): TypedContractToken<T>Defines a typed HTTP contract for a group of route handlers - a thin shorthand over the generic
contract("http", descriptor) core.
A contract declares each handler’s inputs (body, route segments, query) and outputs (response
schemas). Attach it to a controller (static contract) or a route group so the framework can parse
and validate requests and responses. TypeScript infers the full contract type from the descriptor.
descriptor T · An object whose keys are handler method names and values are
RequestDescriptor objects describing that handler's shape.
returns TypedContractToken<T>
Example:
const UserContract = httpContract({ getUser: { route: { id: int }, response: { 200: UserSchema } }, createUser: { body: UserSchema, response: { 201: UserSchema, 400: ErrorSchema } },});Learn: HTTP contracts