(
@CurrentAuth() auth: AuthContext,
@Body(new ZodValidationPipe(CreateApiKeySchema)) dto: CreateApiKeyDto,
)
| 50 | @Roles('ADMIN') |
| 51 | @ApiCreatedResponse({ type: CreateApiKeyResponseDto }) |
| 52 | async create( |
| 53 | @CurrentAuth() auth: AuthContext, |
| 54 | @Body(new ZodValidationPipe(CreateApiKeySchema)) dto: CreateApiKeyDto, |
| 55 | ) { |
| 56 | const { apiKey, plainKey } = await this.apiKeysService.create(auth, dto); |
| 57 | // Return the response DTO plus the plain key (one-time only) |
| 58 | return { |
| 59 | ...ApiKeyResponseDto.create(apiKey), |
| 60 | plainKey, |
| 61 | }; |
| 62 | } |
| 63 | |
| 64 | @Get(':id') |
| 65 | @ApiOkResponse({ type: ApiKeyResponseDto }) |