UNPKG

@curveball/core

Version:

Curveball is a framework writting in Typescript for Node.js

78 lines (77 loc) 2.27 kB
import { NodeHttpResponse } from './http-utils.js'; import NodeHeaders from './response-headers.js'; import { Response, HeadersInterface, HeadersObject, Middleware } from '@curveball/kernel'; export declare class NodeResponse<T> implements Response<T> { private inner; private bodyValue; private explicitStatus; constructor(inner: NodeHttpResponse, origin: string); /** * List of HTTP Headers */ get headers(): NodeHeaders; /** * HTTP status code. */ get status(): number; /** * Updates the HTTP status code for this response. */ set status(value: number); /** * Updates the response body. */ set body(value: T); /** * Returns the response body. */ get body(): T; /** * Sends an informational response before the real response. * * This can be used to for example send a `100 Continue` or `103 Early Hints` * response. */ sendInformational(status: number, headers?: HeadersInterface | HeadersObject): Promise<void>; /** * Sends a HTTP/2 push. * * The passed middleware will be called with a new Context object specific * for pushes. */ push(callback: Middleware): Promise<void>; /** * Returns the value of the Content-Type header, with any additional * parameters such as charset= removed. * * If there was no Content-Type header, an empty string will be returned. */ get type(): string; /** * Shortcut for setting the Content-Type header. */ set type(value: string); /** * This method will return true or false if a Request or Response has a * Content-Type header that matches the argument. * * For example, if the Content-Type header has the value: application/hal+json, * then the arguments will all return true: * * * application/hal+json * * application/json * * hal+json * * json * * application/* */ is(type: string): boolean; redirect(address: string): void; redirect(status: number, address: string): void; /** * Public base URL * * This will be used to determine the absoluteUrl */ readonly origin: string; } export default NodeResponse;