import { ISGManifestEntry, ModuleRegistry, PrachtApp, ResolvedApiRoute } from "@pracht/core/server"; import { IncomingMessage, ServerResponse } from "node:http"; import { PrachtAdapter } from "@pracht/vite-plugin"; //#region src/node-static.d.ts type HeadersManifest = Record>; //#endregion //#region src/node-handler.d.ts interface NodeAdapterContextArgs { request: Request; req: IncomingMessage; res: ServerResponse; } interface NodeAdapterOptions { app: PrachtApp; registry?: ModuleRegistry; staticDir?: string; viteManifest?: unknown; isgManifest?: Record; apiRoutes?: ResolvedApiRoute[]; clientEntryUrl?: string; cssManifest?: Record; jsManifest?: Record; headersManifest?: HeadersManifest; createContext?: (args: NodeAdapterContextArgs) => TContext | Promise; /** * Canonical public origin for request URL construction. When set, the Node * adapter ignores `Host` / forwarded host headers and always builds * `request.url` against this origin. */ canonicalOrigin?: string; /** * Whether to trust proxy headers (`Forwarded`, `X-Forwarded-Proto`, * `X-Forwarded-Host`) when constructing the request URL. * * When `canonicalOrigin` is set, it takes precedence and these headers are * ignored for URL construction. * * When **false** (the default) and no `canonicalOrigin` is set, the request * URL is derived from the socket: protocol is inferred from TLS state, and * host from the `Host` header. Forwarded headers are ignored. * * When **true**, forwarded headers are honored with the following precedence: * 1. RFC 7239 `Forwarded` header (`proto=` and `host=` directives) * 2. `X-Forwarded-Proto` / `X-Forwarded-Host` * 3. Socket-derived values (fallback) * * Enable this only when the Node server sits behind a trusted reverse proxy * (e.g. nginx, Cloudflare, a load balancer) that sets these headers. */ trustProxy?: boolean; /** Maximum request body size in bytes. Defaults to 1 MiB. */ maxBodySize?: number; } declare function createNodeRequestHandler(options: NodeAdapterOptions): (req: IncomingMessage, res: ServerResponse) => Promise; //#endregion //#region src/node-entry.d.ts interface NodeServerEntryModuleOptions { canonicalOrigin?: string; port?: number; /** Vite-resolvable module path exporting `createContext(args)`. */ createContextFrom?: string; /** Maximum request body size in bytes. Defaults to 1 MiB. */ maxBodySize?: number; } declare function createNodeServerEntryModule(options?: NodeServerEntryModuleOptions): string; /** * Create a pracht adapter for Node.js. * * ```ts * import { nodeAdapter } from "@pracht/adapter-node"; * pracht({ adapter: nodeAdapter() }) * ``` */ declare function nodeAdapter(options?: NodeServerEntryModuleOptions): PrachtAdapter; //#endregion export { type NodeAdapterContextArgs, type NodeAdapterOptions, type NodeServerEntryModuleOptions, createNodeRequestHandler, createNodeServerEntryModule, nodeAdapter };