dino-express
Version:
DinO enabled REST framework based on express
39 lines (38 loc) • 1.21 kB
TypeScript
import { type Response } from '../Response';
import { type NextFunction, type Request } from 'express';
export declare abstract class AbstractPolicy {
/**
* Execute the policy logic and allow integration with express
* @param req the client request
* @param res the client response
* @param next a callback invoked when the middleware terminates successfully
*
* @public
*/
middleware(req: Request, res: Response, next: NextFunction): void;
/**
* Apply the requested policy
* @param {Any} req the incoming request
* @returns {Boolean} true if the policy once applied allow access to the API, false otherwise
*
* @protected
* @abstract
*/
abstract apply(_req: Request): boolean;
/**
* Allow to configure this policy
* @param {Any} configuration the policy configuration
*
* @public
* @abstract
*/
abstract configure(_configuration: any): void;
/**
* Execute logic that will signal that the policy has denied the client request
* @param {Any} res the client response
*
* @abstract
* @protected
*/
protected abstract onDeny(_res: Response): void;
}