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 ​
| Parameter | Type | Description |
|---|---|---|
policy | PolicyImplementation | the 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 ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | the express request to handle. |
res | Response | the express response object. |
next | Function | the express next function to continue processing of the request. |
Returns ​
Promise<void>