@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
71 lines (70 loc) • 2.69 kB
TypeScript
import { IncomingHeaders } from '../requests/containers';
/**
* Base class for HTTP responses.
* Encapsulates response payload, status code, and headers.
*/
export declare class BasicResponse {
content: any;
code: number;
/**
* HTTP headers for the response.
*/
headers: IncomingHeaders;
/**
* Creates a new BasicResponse.
*
* @param content - The response payload (body).
* @param code - HTTP status code (100-599). Defaults to 200.
* @param headers - Optional raw headers object or IncomingHeaders instance.
* @throws Error if `code` is outside the valid HTTP range.
*/
constructor(content: any, code?: number, headers?: Record<string, any>);
}
/**
* Internal subclass used to attach a schema name for documentation.
* Not intended for direct use in application code.
*/
export declare class $InternalNamedSigilResponse extends BasicResponse {
/**
* Constructs an internal named response with default values.
*/
constructor();
}
/**
* Primary response class for the Sigil framework.
* Extends BasicResponse and adds schema-based documentation support.
*/
export default class SigilResponse extends BasicResponse {
content: any;
code: number;
/**
* Creates a new SigilResponse.
*
* @param content - The response payload.
* @param code - HTTP status code. Defaults to 200.
* @param headers - Optional raw headers or IncomingHeaders instance.
*/
constructor(content: any, code?: number, headers?: Record<string, any>);
/**
* Creates a named response for OpenAPI schema generation.
* The returned instance carries a `__$schemaName` property.
*
* @param name - Schema name reference for documentation.
* @param content - The response payload.
* @param code - Optional HTTP status code. Defaults to 200.
* @param headers - Optional raw headers object.
* @returns An internal named response instance.
*/
static describe(name: string | null, content: any, code?: number, headers?: Record<string, any>): $InternalNamedSigilResponse;
/**
* Creates a raw named response for OpenAPI schema generation.
* The returned instance carries a `__$schemaName` property.
*
* @param name - Schema name reference for documentation.
* @param content - The response payload.
* @param code - Optional HTTP status code. Defaults to 200.
* @param headers - Optional raw headers object.
* @returns An internal named response instance.
*/
static describeRaw(name: string | null, content: any, code?: number, headers?: Record<string, any>): $InternalNamedSigilResponse;
}