/// /// import { CookieBag } from './cookie-bag.js'; import { OutgoingHttpHeader } from 'node:http'; import { OutgoingHttpHeaders } from 'node:http2'; import { HttpRedirect } from './http-redirect.js'; import { Macroable } from '@supercharge/macroable'; import { ResponseHeaderBag } from './response-header-bag.js'; import { InteractsWithState } from './interacts-with-state.js'; import { CookieConfig, HttpContext, HttpResponse, ResponseCookieBuilderCallback } from '@supercharge/contracts'; declare const Response_base: import("ts-mixer/dist/types/types.js").Class; export declare class Response extends Response_base implements HttpResponse { /** * Stores the internal properties. */ private readonly meta; /** * The default cookie options. */ private readonly cookieConfig; /** * Create a new response instance. */ constructor(ctx: HttpContext, cookieConfig: CookieConfig); /** * Returns the HTTP context instance */ ctx(): HttpContext; /** * Set the response payload. */ payload(payload: any): this; /** * Returns the current response payload. */ getPayload(): T; /** * Returns the response header bag. */ headers(): ResponseHeaderBag; /** * Set a response header with the given `name` and `value`. */ header
(key: Header, value: OutgoingHttpHeaders[Header]): this; header(key: string, value: OutgoingHttpHeader): this; /** * Assign the object’s key-value pairs as response headers. */ withHeaders(headers: { [key: string]: string | string[] | number; }): this; /** * Append a header to the response. If you want to replance a possibly * existing response header, use the `response.header()` method. */ appendHeader(key: string, value: string | string[]): this; /** * Remove the header field for the given `name` from the response. */ removeHeader(name: string): this; /** * Returns the cookie bag. */ cookies(): CookieBag; /** * Assign the given cookie to the response. * * @example * ``` * response.cookie('name', 'value', options) * ``` */ cookie(name: string, value?: string | null, cookieBuilder?: ResponseCookieBuilderCallback): this; /** * Set a response status code to the given `code`. */ status(code: number): this; /** * Returns the response status code. */ getStatus(): number; /** * Determine whether the response has any of the given status `codes` assigned. */ hasStatus(codes: number | number[]): boolean; /** * Determine whether the response has the status code `200 OK`. * * @example * ``` * response.isOk() * // true * ``` */ isOk(): boolean; /** * Determine whether the response has one of the status codes `204` or `304`. */ isEmpty(): boolean; /** * Set the response `Content-Type` header. This will look up the mime type * and set the related value as the content type header field. It also * removes the content type header if no valid mime type is available. */ type(contentType: string): this; /** * Set the response ETag. This will normalize quotes if necessary. */ etag(etag: string): this; /** * Temporarily redirect the request using HTTP status code 302. You can customize * the redirect when omitting any parameter to this `response.redirect()` method. */ redirect(): HttpRedirect; redirect(url: string): HttpRedirect; /** * Permanently redirect the request using HTTP status code 301. */ permanentRedirect(): HttpRedirect; permanentRedirect(url: string): HttpRedirect; /** * Determine whether the response is an HTTP redirect using one of the status * codes in range 300 to 399. You may also determine whether the response is * a redirect using a `statusCode` value that you provide as an argument. */ isRedirect(statusCode?: number): boolean; /** * Abort the request and throw an error with the given `status`. The status defaults * to 500. You may pass an error message or error instance as the second argument. * Use the third, optional argument for properties in the error response. */ throw(status: number, message?: string | Error, properties?: {}): void; } export {};