import type { ResolvedNixConfig } from "../config/index.js"; export interface RouteTable { pages: import("../router/route-scanner.js").PageRoute[]; api: import("../router/route-scanner.js").ApiRoute[]; error404?: import("../router/route-scanner.js").PageRoute; error500?: import("../router/route-scanner.js").PageRoute; } /** Read-only access to request cookies. */ export interface CookieJar { /** Gets a cookie value by name, or undefined if not present. */ get(name: string): string | undefined; /** Returns all cookie name-value pairs. */ getAll(): Record; /** Checks if a cookie exists. */ has(name: string): boolean; } /** Write access to response cookies (Set-Cookie headers). */ export interface ResponseCookieJar { /** Sets a Set-Cookie header. */ set(name: string, value: string, options?: CookieOptions): void; /** Removes a cookie by setting it expired. */ clear(name: string, options?: CookieOptions): void; /** Returns all Set-Cookie header values accumulated so far. */ getAll(): string[]; } export interface CookieOptions { httpOnly?: boolean; secure?: boolean; sameSite?: "strict" | "lax" | "none"; maxAge?: number; expires?: Date; path?: string; domain?: string; } /** Mutable response state accumulated during the request lifecycle. */ export interface ResponseState { status?: number; headers: Headers; cookies: ResponseCookieJar; } export interface RequestContextOptions { request: Request; config: ResolvedNixConfig; routes: RouteTable; actions: import("../action/scan.js").ActionRegistry; /** Public action names serialized into the HTML shell. */ publicActions: Record; /** Optional module loader for adapter-bundled entries. */ importer?: (path: string) => unknown | Promise; /** Whether the render endpoint (/__nix-js/render) is available. */ renderEndpoint?: boolean; /** Whether to bypass the ISR cache (dev mode). */ noCache?: boolean; /** ISR cache directory (absolute). */ cacheDir?: string; /** Default ISR revalidate interval in seconds. */ defaultRevalidate?: number; /** Route params (populated after route matching). */ params?: Record; /** Per-request locals (populated by middleware). */ locals?: Record; /** Abort signal for the request (from host disconnect). */ signal?: AbortSignal; /** Request ID (auto-generated if not provided). */ requestId?: string; /** Platform-specific context (e.g. Vercel, Netlify). */ platform?: unknown; /** Matched route (populated after route matching). */ route?: import("../router/route-scanner.js").PageRoute | import("../router/route-scanner.js").ApiRoute; } export declare class RequestContext { readonly request: Request; readonly url: URL; readonly config: ResolvedNixConfig; readonly routes: RouteTable; readonly actions: import("../action/scan.js").ActionRegistry; readonly publicActions: Record; readonly importer?: (path: string) => unknown | Promise; readonly renderEndpoint: boolean; readonly noCache: boolean; readonly cacheDir?: string; readonly defaultRevalidate?: number; /** Route params derived from the matched route. */ params: Readonly>; /** Per-request locals, populated by middleware. Not global. */ locals: Record; /** Read-only access to request cookies. */ readonly cookies: CookieJar; /** Abort signal (from host disconnect when platform allows). */ readonly signal: AbortSignal; /** Unique request ID for logging/correlation. */ readonly requestId: string; /** Platform-specific context (Vercel, Netlify, etc.). */ readonly platform: unknown; /** Matched route after route matching. */ route?: import("../router/route-scanner.js").PageRoute | import("../router/route-scanner.js").ApiRoute; /** Mutable response state accumulated during the request. */ readonly response: ResponseState; constructor(options: RequestContextOptions); /** The pathname without a query string. */ get pathname(): string; /** The HTTP method, uppercased. */ get method(): string; /** Whether the request accepts JSON. */ get wantsJson(): boolean; /** Search params from the request URL. */ get searchParams(): URLSearchParams; /** Render config passed to renderPage/renderErrorPage. */ get renderConfig(): { lang?: string; clientEntry?: string; renderEndpoint?: boolean; }; /** Applies accumulated response state (headers, cookies, status) to a Response. */ applyToResponse(response: Response): Response; } export declare function htmlResponse(body: string, status?: number, headers?: HeadersInit): Response; export declare function jsonResponse(data: unknown, status?: number, headers?: HeadersInit): Response; export declare function textResponse(body: string, status?: number, headers?: HeadersInit): Response; export declare function notFound(body?: string): Response; export declare function methodNotAllowed(method: string): Response; export declare function serverError(body: string): Response; export declare function guessContentType(filePath: string): string; /** * Serves a static file from the root directory with full conditional and * range support: * * - ETag / Last-Modified with If-None-Match / If-Modified-Since → 304. * - `Range` with `If-Range` (ETag or date) → 206 with `Content-Range`. * - HEAD → same headers as GET without a body. * - Invalid/unsatisfiable ranges → 416 with a `Content-Range: bytes (asterisk)/size` header. * * Files with content hashes in their names (e.g. `app-abc123.js`) get * `Cache-Control: public, max-age=31536000, immutable`. * * @param root Static file root (absolute path). * @param pathname Request pathname. * @param request Optional request for conditional/range/HEAD handling. */ export declare function serveStaticFile(root: string, pathname: string, request?: Request): Promise;