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,
Delete,
Inject,
Param,
Post,
UseGuards,
} from "@nestjs/common";
@ -28,8 +29,8 @@ export class ApiController {
return this.apiService.generateToken(body.id);
}
@Delete("token/revoke")
revokeToken(@Body() body: { token: string }) {
return this.apiService.revokeToken(body.token);
@Delete("token/revoke/:token")
revokeToken(@Param("token") token: string) {
return this.apiService.revokeToken(token);
}
}

View File

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

View File

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