Both guards are redefining the jwt functions on every call. In consequence, every API call leads to a new call to Auth0 - very bad for performance.
Looking at https://github.com/auth0-developer-hub/api_nestjs_typescript_hello-world/blob/main/src/authorization/authorization.guard.ts#L22, I think it should be:
...
export class AuthorizationGuard implements CanActivate {
private validateAccessToken = promisify(auth());
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest<Request>();
const response = context.switchToHttp().getResponse<Response>();
try {
await this.validateAccessToken(request, response);
...
Same for https://github.com/auth0-developer-hub/api_nestjs_typescript_hello-world/blob/main/src/authorization/permissions.guard.ts
Please do not use this repository as is.
Both guards are redefining the jwt functions on every call. In consequence, every API call leads to a new call to Auth0 - very bad for performance.
Looking at https://github.com/auth0-developer-hub/api_nestjs_typescript_hello-world/blob/main/src/authorization/authorization.guard.ts#L22, I think it should be:
Same for https://github.com/auth0-developer-hub/api_nestjs_typescript_hello-world/blob/main/src/authorization/permissions.guard.ts
Please do not use this repository as is.