@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
48 lines (47 loc) • 1.93 kB
TypeScript
import { HttpMethod } from '@sigiljs/pathfinder';
import { default as IncomingHeaders } from './incoming-headers';
import { ClientIpInfo } from '../get-client-ip-info';
import { Internal } from '../../types';
/**
* Container for processed request data ready to create a client request.
* Holds routing, protocol, host, and path information, along with parsed payload.
*
* @example
* const processorResponse = new IncomingRequestProcessorResponse(options)
* const clientReq = processorResponse.createClientRequest({ id: "123" })
*/
export default class IncomingRequestProcessorResponse {
#private;
/** Protocol used ("http" or "https"). */
readonly protocol: string;
/** Host header from the incoming request. */
readonly host: string;
/** Pathname of the request URL. */
readonly path: string;
/** HTTP method of the request. */
readonly method: HttpMethod;
/** Request headers */
readonly headers: IncomingHeaders;
/** Client IP information. */
readonly remoteAddress: ClientIpInfo;
/**
* Initializes a new IncomingRequestProcessorResponse with parsed data.
*
* @param options full request processor response, including headers, query, body, files, etc.
*/
constructor(options: Internal.Requests.FullRequestProcessorResponse);
/**
* Creates or returns a cached client request object for downstream handlers.
*
* @template T type of the path parameters map.
* @param params object mapping path parameter names to values.
* @returns ClientRequest object combining processor response data and params.
*/
createClientRequest<T extends Record<string, string>>(params: T): Internal.Requests.ClientRequest<T>;
/**
* Builds and returns the full request URI as a URL object.
*
* @returns URL instance representing the full request URI, or null if invalid.
*/
fullUri(): URL | null;
}