Files
paperlessmanager/paperless-backend/src/auth/api-keys.controller.ts
T
bjoernpoettker dad0136365
Build and Push Multi-Platform Images / build-and-push (push) Successful in 41s
chore: apply ESLint auto-fix across entire backend
Reformats code style (line breaks, indentation, type annotations)
without changing logic. Also includes minor feature additions bundled
in the same lint run (stats service, user-settings groups, agrarmonitor
polling improvements).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-08 09:02:02 +02:00

35 lines
833 B
TypeScript

import {
Controller,
Get,
Post,
Delete,
Body,
Param,
UseGuards,
} from '@nestjs/common';
import { ApiKeysService } from './api-keys.service';
import { JwtAuthGuard } from './jwt-auth.guard';
@Controller('api/api-keys')
@UseGuards(JwtAuthGuard)
export class ApiKeysController {
constructor(private readonly apiKeysService: ApiKeysService) {}
@Post()
async create(@Body() body: { name: string; expiresDays?: number }) {
// Note: The plainKey is only returned here once.
return this.apiKeysService.createApiKey(body.name, body.expiresDays);
}
@Get()
async findAll() {
// Note: This returns hashed keys and prefixes, not the plain keys.
return this.apiKeysService.listKeys();
}
@Delete(':id')
async remove(@Param('id') id: string) {
return this.apiKeysService.deleteKey(id);
}
}