@sauce-api/core
Version:
Sauce API core functionality
21 lines (20 loc) • 1.2 kB
TypeScript
import { Response } from "express";
import { ObjectOfAnything } from "./resources/Common";
import { IArrayResponse, IErrorResponse, IPaginatedResponse, IResponse } from "./resources/IResponses";
import { PaginatedObject } from "./resources/PaginationTypes";
export declare class Responses {
private res;
constructor(res: Response);
responseText(code: 200, data: string | number): void;
responseObject(code: 200, data: ObjectOfAnything): void;
responsePaginated(code: 200, paginatedData: PaginatedObject): void;
responseArray(code: 200, data: Array<any>): void;
badRequest(data: any, options?: any): void;
serverError(data: any, options?: any): void;
notFound(data: any, options?: any): void;
unauthorized(data: any, options?: any): void;
}
export declare const formatObjectResponse: (code: number, data: ObjectOfAnything) => IResponse;
export declare const formatPaginatedResponse: (code: number, paginatedData: PaginatedObject) => IPaginatedResponse;
export declare const formatArrayResponse: (code: number, data: Array<any>) => IArrayResponse;
export declare const formatErrorResponse: (code: number, error: string, errorDescription?: any) => IErrorResponse;