@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
52 lines (51 loc) • 1.53 kB
JavaScript
import e from "../../utils/safe-url.mjs";
class r {
/** Protocol used ("http" or "https"). */
protocol;
/** Host header from the incoming request. */
host;
/** Pathname of the request URL. */
path;
/** HTTP method of the request. */
method;
/** Request headers */
headers;
/** Client IP information. */
remoteAddress;
/** Cached client request object once created. */
#t;
/** Internal full request processor response data. */
#e;
/**
* Initializes a new IncomingRequestProcessorResponse with parsed data.
*
* @param options full request processor response, including headers, query, body, files, etc.
*/
constructor(t) {
this.#e = t, this.headers = t.headers, this.host = t.host, this.path = t.path, this.method = t.method, this.protocol = t.protocol, this.remoteAddress = t.remoteAddress;
}
/**
* 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) {
return this.#t ? this.#t : (this.#t = {
...this.#e,
params: t
}, this.#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() {
return e(`${this.protocol}://${this.host}${this.path}`);
}
}
export {
r as default
};