Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Make req.user optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 18, 2020
1 parent 516f937 commit a8011fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/interceptors/rate-limit.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class RateLimitInterceptor implements NestInterceptor {
const request = context.switchToHttp().getRequest() as UserRequest;
const response = context.switchToHttp().getResponse();
let limiter = this.rateLimiterPublic;
if (request.user.type === 'api-key') limiter = this.rateLimiterApiKey;
else if (request.user.type === 'user')
if (request.user?.type === 'api-key') limiter = this.rateLimiterApiKey;
else if (request.user?.type === 'user')
limiter = this.rateLimiterAuthenticated;
try {
const ip = getClientIp(request);
Expand Down

0 comments on commit a8011fc

Please sign in to comment.