import { BunRequest } from 'bun'; import { ErrorHandler, Handler, Middleware, RouteConfig } from '../types'; export declare class Processor { private readonly req; private readonly routeConfig; private readonly middlewares; private readonly routeHandler; private readonly errorHandler; private readonly rootContext; private store; private readonly requestUrl; private readonly requestHeaders; private readonly requestQuery; private readonly authorizationParser; private readonly cookies; private readonly responseHeaders; private responseStatus; constructor(req: BunRequest, server: Bun.Server, routeConfig: RouteConfig, middlewares: Middleware[], // initial global middlewares array routeHandler: Handler, errorHandler: ErrorHandler); /** * Safely parse the request body based on its Content-Type. * * - Skips parsing for `GET`, `HEAD`, and `OPTIONS` (these methods don’t carry a body). * - If `Content-Length` is present and `0`, parsing is skipped. * - `application/json`, `multipart/form-data`, and `application/x-www-form-urlencoded` * are parsed accordingly by `BodyParser`. * - Any other supported type is parsed as text and wrapped as `{ content: string }`. * * The raw (unparsed) body is stored in `rootContext.rawBody` when available. * * Parsing is performed on a cloned (`clone()`) instance of the request, * so the original request stream remains readable and can be used afterward. * * @see BodyParser * @remarks This method is defensive: unexpected parser errors are logged and swallowed. */ private parseBody; private validateContentType; private getHandlerContext; private findFirstSuccessResponse; private parseSuccessResult; /** * Normalizes an awaited `Result` value into a `Response` instance. * * Accepted types: * - `Response` → returned as-is. * - `null` → empty body * - `string` → plain text * - `object` → serializes JSON body * * Error handling: * - Throws `InternalServerError` if Result is not null - string - object or Response * * @param result - The handler or middleware return value to normalize. * @returns A `Response` object ready to be returned to the client. */ private createResponse; /** * Exception to Response with Error handler * its parsed within another try-catch, because if at error fails "we will never know what happen" * @param ex */ private createErrorResponse; execute(): Promise; }