Rest
...args: [options: EnsureBearerTokenProviderOptions] // Register it on the container
container.register(ensureBearerTokenProvider);
// Let's assume we are in a controller now...
// Getting access to the middleware.
const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');
// Register it on the container
container.register(
ensureBearerTokenProvider({
serviceName: 'ensureBearerTokenCustom',
error: {
message: 'Missing token!',
},
}),
);
Generated using TypeDoc
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.