(auth: AuthContext, id: string, dto: UpdateApiKeyDto)
| 92 | } |
| 93 | |
| 94 | async update(auth: AuthContext, id: string, dto: UpdateApiKeyDto) { |
| 95 | if (!auth.organizationId) { |
| 96 | throw new NotFoundException('API key not found'); |
| 97 | } |
| 98 | |
| 99 | const [apiKey] = await this.db |
| 100 | .update(apiKeys) |
| 101 | .set({ |
| 102 | ...dto, |
| 103 | updatedAt: new Date(), |
| 104 | }) |
| 105 | .where(and(eq(apiKeys.id, id), eq(apiKeys.organizationId, auth.organizationId))) |
| 106 | .returning(); |
| 107 | |
| 108 | if (!apiKey) { |
| 109 | throw new NotFoundException('API key not found'); |
| 110 | } |
| 111 | |
| 112 | return apiKey; |
| 113 | } |
| 114 | |
| 115 | async delete(auth: AuthContext, id: string) { |
| 116 | if (!auth.organizationId) { |
no test coverage detected