UNPKG

@honorestjs/contract

Version:

Contract-first API definitions for HonorestJS - Framework-agnostic contract definitions with full type safety

43 lines 1.65 kB
/** * @honorestjs/contract * * Framework-agnostic contract definitions for type-safe APIs * * This package provides tools for defining API contracts that can be: * - Shared between server and clients * - Validated at runtime * - Used to generate OpenAPI specs * - Consumed by any framework * * @example * ```typescript * import { defineContract, endpoint } from '@honorestjs/contract' * import { z } from 'zod' * * const UsersContract = defineContract({ * name: 'users', * path: '/users', * endpoints: { * getUser: endpoint({ * method: 'GET', * path: '/:id', * params: z.object({ id: z.string().uuid() }), * output: z.object({ * id: z.string().uuid(), * name: z.string(), * email: z.string().email() * }) * }) * } * }) * ``` * * @packageDocumentation */ export { endpoint, defineContract, defineApp } from './builder'; export { isEndpoint, isContract, isApp } from './builder'; export type { EndpointDefinition, Endpoint, HttpMethod, ContractDefinition, Contract, AppDefinition, App, AppMetadata } from './builder'; export type { InferEndpointInput, InferEndpointOutput, InferEndpointErrors, ContractInput, ContractOutput, ContractErrors, ContractEndpoints, AppContracts, AppContract, ContractInputs, ContractOutputs, DefinedInput, OptionalNever } from './types'; export { validate, validateSync, validateEndpointInput, validateEndpointOutput, validateEndpointError, formatValidationError } from './validator'; export type { ValidationResult, ValidationError, EndpointInputValidation } from './validator'; //# sourceMappingURL=index.d.ts.map