dino-express
Version:
DinO enabled REST framework based on express
53 lines (52 loc) • 2.55 kB
TypeScript
/// <reference types="node" />
import { type Response as EResponse } from 'express';
import { type GenericCallback, type GenericObject } from './Types';
import { HttpException } from './exception/http.exception';
import { type CookieOptions, type Locals, type Application, type Request, type ParamsDictionary } from 'express-serve-static-core';
import { type ParsedQs } from 'qs';
import { type RuntimeContext } from './RuntimeContext';
import http from 'http';
export type ResponsePayload = GenericObject | string | undefined;
export type ErrorResponsePayload = GenericObject | HttpException | Error | undefined;
/**
* The response that is returned from the API handler.
* @public
*/
export interface Response extends EResponse {
body: ResponsePayload;
}
export declare class ResponseImpl extends http.ServerResponse implements Response {
body: ResponsePayload;
app: Application<Record<string, any>>;
locals: Record<string, any> & Locals;
charset: string;
readonly req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>;
private readonly callback;
private readonly runtimeContext;
private readonly responseAdaptorStrategySelector;
constructor(callback: GenericCallback<any>, req: Request, runtimeContext: RuntimeContext);
sendfile(_path: unknown, _options?: unknown, _fn?: unknown): void;
status(code: number): any;
sendStatus(_code: number): this;
links(_links: any): this;
send(_body?: GenericObject): any;
json(body?: GenericObject): any;
jsonp(body?: GenericObject): any;
sendFile(_path: unknown, _options?: unknown, _fn?: unknown): void;
download(_path: unknown, _filename?: unknown, _options?: unknown, _fn?: unknown): void;
contentType(type: string): this;
type(type: string): this;
format(obj: GenericObject): this;
accepts(types: string[]): string | undefined;
attachment(_filename?: string | undefined): this;
set(field: string, value?: string | number | readonly string[]): this;
header(field: string, value?: string | number | readonly string[]): this;
get(field: string): string | undefined;
clearCookie(_name: string, _options?: CookieOptions | undefined): this;
cookie(_name: unknown, _val: unknown, _options?: unknown): this;
location(url: string): this;
redirect(_url: unknown, _status?: unknown): void;
render(_view: unknown, _options?: unknown, _callback?: unknown): void;
vary(field: string): this;
append(field: string, value?: string | string[] | undefined): this;
}