/** * 框架无关的 API 请求上下文(原 Hono Context 子集) * 模块 API handler 通过此接口访问请求/响应,平台可用 Elysia 等任意框架适配。 */ export type ApiStatusCode = number; export interface ApiRequestContext { req: { raw: Request; param: (name: string) => string | undefined; query: (name: string) => string | undefined; header: (name: string) => string | undefined; json: () => Promise; path: string; method: string; }; json: (data: unknown, status?: ApiStatusCode) => Response; header: (name: string, value: string) => void; get: (key: string) => T; set: (key: string, value: unknown) => void; } export type ApiMiddleware = ( c: ApiRequestContext, next: () => Promise, ) => Promise | Response | void;