import { InjectorContext, Setter } from '@deepkit/injector'; import { HttpRouter } from './router.js'; import { EventDispatcher } from '@deepkit/event'; import { LoggerInterface } from '@deepkit/logger'; import { HttpRequest, HttpResponse, MemoryHttpResponse, RequestBuilder } from './model.js'; import { Stopwatch } from '@deepkit/stopwatch'; import { IncomingMessage, ServerResponse } from 'http'; interface HttpKernelHandleOptions { /** * Makes the kernel throw a HttpNotFoundError when the route is not found * or a controller threw a HttpNotFoundError. This allows you to catch * the error and handle it yourself. */ throwOnNotFound?: boolean; } interface HttpKernelMiddlewareOptions extends HttpKernelHandleOptions { /** * If true, a HttpNotFoundError or missing route is not automatically * sent to the client. Instead, the request is passed to the next middleware. */ fallThroughOnNotFound?: boolean; } export declare class HttpKernel { protected router: HttpRouter; protected eventDispatcher: EventDispatcher; protected injectorContext: InjectorContext; protected logger: LoggerInterface; protected stopwatch: Stopwatch; protected setHttpRequest: Setter; protected setHttpResponse: Setter; protected setInjectorContext: Setter; constructor(router: HttpRouter, eventDispatcher: EventDispatcher, injectorContext: InjectorContext, logger: LoggerInterface, stopwatch: Stopwatch); /** * Creates a request handler function that can be used with http.createServer * or any other http server library based on the node.js http module. * * When `fallThroughOnNotFound` is set to true, the handler will call `next()` * when the route is not found, allowing the request to fall through to the next * middleware in the chain. * * @example * ```typescript * import { createServer } from 'http'; * * const app = new App({ * imports: [new HttpModule({})], * }); * * const handler = app.get(HttpKernel).createMiddleware({ fallThroughOnNotFound: true }); * const server = createServer(handler); * * server.listen(3000); * ``` */ createMiddleware(options?: HttpKernelMiddlewareOptions): (req: IncomingMessage, res: ServerResponse, next: (error?: any) => void) => Promise; request(requestBuilder: RequestBuilder, options?: HttpKernelHandleOptions): Promise; handleRequest(_req: IncomingMessage, _res: ServerResponse, options?: HttpKernelHandleOptions): Promise; } export {};