Generates a "service middleware" that can be used on route controllers in order to
validate the presence of a bearer token on the requests authorization header.
The registered service is an instance of EnsureBearerToken, and it uses the key
ensureBearerToken.
Since it's a "provider creator", when registering it, you can pass custom options.
Example: Basic usage
// Register it on the container container.register(ensureBearerTokenProvider);
// Let's assume we are in a controller now... // Getting access to the middleware. constensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');
Example: Customizing the service
// Register it on the container container.register( ensureBearerTokenProvider({ serviceName:'ensureBearerTokenCustom', error: { message:'Missing token!', }, }), );
Generates a "service middleware" that can be used on route controllers in order to validate the presence of a bearer token on the requests authorization header.
The registered service is an instance of EnsureBearerToken, and it uses the key
ensureBearerToken
.Since it's a "provider creator", when registering it, you can pass custom options.
Example: Basic usage
Example: Customizing the service