fix: update token revoke and settings delete endpoints to use route parameters

This commit is contained in:
lborv
2025-10-25 16:58:22 +03:00
parent 0f0d082a17
commit 0180c4115c
3 changed files with 11 additions and 10 deletions

View File

@ -3,6 +3,7 @@ import {
Controller, Controller,
Delete, Delete,
Inject, Inject,
Param,
Post, Post,
UseGuards, UseGuards,
} from "@nestjs/common"; } from "@nestjs/common";
@ -28,8 +29,8 @@ export class ApiController {
return this.apiService.generateToken(body.id); return this.apiService.generateToken(body.id);
} }
@Delete("token/revoke") @Delete("token/revoke/:token")
revokeToken(@Body() body: { token: string }) { revokeToken(@Param("token") token: string) {
return this.apiService.revokeToken(body.token); return this.apiService.revokeToken(token);
} }
} }

View File

@ -4,6 +4,7 @@ import {
Delete, Delete,
Get, Get,
Inject, Inject,
Param,
Put, Put,
Req, Req,
UseGuards, UseGuards,
@ -46,12 +47,12 @@ export class ProjectController {
); );
} }
@Delete("settings/delete") @Delete("settings/delete/:key")
deleteSetting( deleteSetting(
@Body() body: { key: string }, @Param("key") key: string,
@Req() req: Request & { apiToken: { id: string } } @Req() req: Request & { apiToken: { id: string } }
) { ) {
return this.projectSettingService.delete(req.apiToken.id, body.key); return this.projectSettingService.delete(req.apiToken.id, key);
} }
@Get("settings") @Get("settings")
@ -63,6 +64,5 @@ export class ProjectController {
@UseGuards(AdminGuard) @UseGuards(AdminGuard)
getAllApiTokens(@Req() req: Request & { apiToken: { id: string } }) { getAllApiTokens(@Req() req: Request & { apiToken: { id: string } }) {
return this.projectService.getAllApiTokens(req.apiToken.id); return this.projectService.getAllApiTokens(req.apiToken.id);
} }
}
}

View File

@ -76,7 +76,7 @@ export class ProjectService {
redisNodes: redisNodeId, redisNodes: redisNodeId,
}); });
} }
async getAllApiTokens(projectId: string) { async getAllApiTokens(projectId: string) {
const project = await this.projectRepository.findOne({ const project = await this.projectRepository.findOne({
where: { id: projectId }, where: { id: projectId },