http-handler-response
Version:
A simple response handler for HTTP requests.
68 lines • 2.24 kB
TypeScript
import { INFORMATIONAL, REDIRECTION, SUCCESS, CLIENT_ERROR, SERVER_ERROR } from './constants';
/**
* H T T P
*/
export declare type TInformationalCode = keyof typeof INFORMATIONAL;
export declare type TSuccessCode = keyof typeof SUCCESS;
export declare type TRedirectionCode = keyof typeof REDIRECTION;
export declare type TClientErrorCode = keyof typeof CLIENT_ERROR;
export declare type TServerErrorCode = keyof typeof SERVER_ERROR;
export declare type TInformational = typeof INFORMATIONAL[TInformationalCode];
export declare type TSuccess = typeof SUCCESS[TSuccessCode];
export declare type TRedirection = typeof REDIRECTION[TRedirectionCode];
export declare type TClientError = typeof CLIENT_ERROR[TClientErrorCode];
export declare type TServerError = typeof SERVER_ERROR[TServerErrorCode];
export declare type TRootResponseCode = TInformationalCode | TSuccessCode | TRedirectionCode;
export declare type TRootResponse = TInformational | TSuccess | TRedirection;
export declare type TRootErrorCode = TClientErrorCode | TServerErrorCode;
export declare type TRootError = TClientError | TServerError;
export declare type TRootCode = TRootResponseCode | TRootErrorCode;
/**
* B U I L D E R S
*/
export interface ICreateModelMessage {
code: number | string;
title?: string;
}
export interface IModelMessage {
status: number;
title: string;
}
export interface ICreateResponse {
code: TRootResponse | TRootResponseCode;
message?: string;
title?: string;
data?: [] | object;
}
export interface ICreateException {
code: TRootError | TRootErrorCode;
detail: string;
title?: string;
type?: string;
instance?: string;
}
export interface IModelResponse extends IModelMessage {
message?: string;
data?: object;
}
export interface IModelError extends IModelMessage {
detail: string;
type?: string;
instance?: string;
}
/**
* H A N D L E R S
*/
export interface IHandler {
response: IResponse;
json: IModelResponse | IModelError;
}
export interface IResponse {
status: any;
json?: any;
body?: any;
type?: any;
send: any;
app?: any;
}
//# sourceMappingURL=types.d.ts.map