Skip to content

SudoSOS Back-end API / internal/middleware / PolicyMiddleware

Class: PolicyMiddleware ​

This class is responsible for:

  • enforcing a given policy implementation as middleware.

Constructors ​

Constructor ​

ts
new PolicyMiddleware(policy): PolicyMiddleware;

Creates a new policy middleware instance.

Parameters ​

ParameterTypeDescription
policyPolicyImplementationthe policy to be used by this middleware.

Returns ​

PolicyMiddleware

Methods ​

getMiddleware() ​

ts
getMiddleware(): RequestHandler;

Returns ​

RequestHandler

a middleware handler to be used by express.


handle() ​

ts
handle(
   req, 
   res, 
next): Promise<void>;

Middleware handler for enforcing the policy.

Parameters ​

ParameterTypeDescription
reqRequestWithTokenthe express request to handle.
resResponsethe express response object.
nextFunctionthe express next function to continue processing of the request.

Returns ​

Promise<void>