import type { RuntimeAdapter } from "../../platform/adapters/base.js"; import { getConfig } from "../../config/index.js"; import { type APIContext } from "./context-builder.js"; import type { APIRoute } from "./module-loader/types.js"; import { loadHandlerModule, prepareHandlerModule } from "./module-loader/loader.js"; import { discoverAppRoutes, discoverPagesRoutes } from "./route-discovery.js"; import type { HandlerContext } from "../../types/index.js"; export type { APIContext, APIRoute }; /** * Reduce a module load error to something safe to put in a response body. * * The message is worth returning, since it usually names a syntax or import * error the developer can act on. The rest of it is not: a raw load error * carries the temp directory the bundle was written to, absolute paths into the * framework install, and a full stack trace. A path inside the project survives * as a project-relative one, because that is the part that identifies the file * to fix. */ export declare function sanitizeLoadErrorForResponse(message: string, projectDir?: string): string; /** * Injection interface for testing APIRouteHandler dependencies */ interface APIRouteHandlerDeps { loadHandlerModule?: typeof loadHandlerModule; prepareHandlerModule?: typeof prepareHandlerModule; discoverPagesRoutes?: typeof discoverPagesRoutes; discoverAppRoutes?: typeof discoverAppRoutes; getConfig?: typeof getConfig; } /** * Inject dependencies for testing. Pass null to reset to defaults. */ export declare function __injectDepsForTests(deps: APIRouteHandlerDeps | null): void; /** Structured response shape for API route helpers. */ export interface APIResponse { body?: unknown; status?: number; headers?: HeadersInit; } /** Function signature for API route handlers. */ export type APIHandler = (ctx: APIContext) => Promise | Response; export declare class APIRouteHandler { private projectDir; private router; private routeCache; private executionScopeId; private activeRequests; private destroyRequested; private destroyed; private adapter; private adapterPromise; private corsConfig; private corsConfigLoaded; private corsConfigPromise; private config; private configPromise; constructor(projectDir: string, adapter?: RuntimeAdapter, config?: Awaited>); initialize(): Promise; handle(request: Request, ctx?: HandlerContext): Promise; private loadRoute; clearCache(): void; destroy(): void; private completeRequest; private destroyNow; private ensureAdapter; private ensureCorsConfig; private loadCorsConfig; private ensureConfig; private loadFullConfig; } export { badRequest, forbidden, internalServerError as serverError, jsonResponse as json, notFound, redirectResponse as redirect, unauthorized, } from "../../platform/compat/http/responses.js"; //# sourceMappingURL=handler.d.ts.map