The options to construct the class.
Protected
Readonly
_HTTPErrorTo generate the errors when the validation fails.
Protected
Readonly
_optionsThe customization options for the service.
The customization options.
Generates the middleware that verifies if a request has an Authorization
header
with a bearer token.
This service gives you a middleware that verifies if a request has an
Authorization
header with a bearer token; if it does, the token will be saved on theres.locals
, otherwise, it will generate an error.This is a "service middleware" to allow certain flexibility: you can have controllers where some routes are protected and others are not. For those cases, you get the service from the container, and include it only in the routes that need it.