import { StatusCode } from './StatusCode'; import { ResponseData } from './ResponseData'; import { StormError, IErrorResponse } from './StormError'; import * as express from 'express'; import { Stream } from 'stream'; import { Application } from './Application'; export type TSupportedResponsePrimitives = number | boolean | string | Date | IErrorResponse | void | TSupportedResponsePrimitives[] | TSerializableResponse; /** * Utility type wrap, useful if you have a concrete interface of TSupportedResponsePrimitives properties. * Use this to declare that your interface is Response Serializable. * * e.g. * * ```typescript * interface MyInterface {...} * type TMyInterface = TSerializableResponse; * ``` * * OR * * ```typescript * type MyInterface = TSerializableResponse<{...}>; * ``` * * NOTE: This actually will allow more than what is within the `TSupportedResponsePrimitives` union type. * TypeScript doesn't offer a way to properly restrict or infer the type. */ export type TSerializableResponse = { [k in keyof T]: TSupportedResponsePrimitives; }; export type TSupportedResponseTypes = TSupportedResponsePrimitives | Error | StormError | Buffer | ReadableStream | Stream.Readable; export interface IHeaderKeyValuePair { [key: string]: string; } export declare class Response { private $app; private $response; private $created; private $requestURL; constructor(app: Application, response: express.Response, requestURL: string); setStatus(status: StatusCode): Response; getStatus(): StatusCode; redirect(url: string): void; private $send; send(data?: TResponse | ResponseData | ResponseData | StormError | IErrorResponse): void; pipe(stream: NodeJS.ReadableStream): void; success(data?: TResponse): void; setHeader(key: string, value: string): void; setHeaders(keyValuePair: IHeaderKeyValuePair): void; isHeadersSent(): boolean; error(error?: StormError | IErrorResponse | ResponseData | unknown): void; }