@szegedsw/lib-node
Version:
A little framework published by Szeged Software Zrt. in order to enhance api endpoint security and create reuseable code. Email module, Logging system, and much more. Further improvements are expected.
45 lines • 1.66 kB
TypeScript
import { Request, Response } from "express";
import { HttpCodes } from "../config/http-codes";
import { Routed } from "../express/router";
import { IErrors, OnError } from "../functions/try";
import { IModel } from "../interfaces/interfaces";
export declare type Guard = (req: Request, res: Response) => boolean;
export interface Controller {
notAcceptableCode?: HttpCodes;
getGuard?: Guard;
postGuard?: Guard;
patchGuard?: Guard;
putGuard?: Guard;
deleteGuard?: Guard;
isSendHelpMessage?: boolean;
getModel?: IModel;
patchModel?: IModel;
postModel?: IModel;
putModel?: IModel;
deleteModel?: IModel;
}
export declare abstract class Controller extends Routed {
abstract get(req: Request, res: Response, data: {
[key: string]: any;
} | undefined): Promise<void>;
abstract post(req: Request, res: Response, data: {
[key: string]: any;
} | undefined): Promise<void>;
abstract patch(req: Request, res: Response, data: {
[key: string]: any;
} | undefined): Promise<void>;
abstract put(req: Request, res: Response, data: {
[key: string]: any;
} | undefined): Promise<void>;
abstract delete(req: Request, res: Response, data: {
[key: string]: any;
} | undefined): Promise<void>;
errors?: IErrors;
splitter?: string;
onError?: OnError;
validator(req: Request, res: Response): Promise<boolean>;
static modelValidator(object: any, model: IModel): boolean;
private static fieldValidator;
protected createHelpResponse(object: any, model: IModel): Promise<string>;
}
//# sourceMappingURL=controller.class.d.ts.map