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

Commit

Permalink
🐛 Return API key data from LRU if available
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 13, 2020
1 parent 89b7bd2 commit b73cd6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/api-keys/api-keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ export class ApiKeysService {
}

async getApiKeyFromKey(key: string): Promise<Expose<apiKeys>> {
if (this.lru.has(key)) return this.lru.get(key);
const apiKey = await this.prisma.apiKeys.findFirst({
where: { apiKey: key },
});
if (!apiKey) throw new NotFoundException(API_KEY_NOT_FOUND);
if (this.lru.has(key)) return this.lru.get(key);
this.lru.set(key, apiKey);
return this.prisma.expose<apiKeys>(apiKey);
}
Expand Down

0 comments on commit b73cd6a

Please sign in to comment.