feat: implement project settings management with CRUD operations and caching

This commit is contained in:
lborv
2025-10-13 20:40:01 +03:00
parent aa7920384c
commit 93f12cd1d8
14 changed files with 304 additions and 17 deletions

View File

@ -1,14 +1,26 @@
import { Body, Controller, Inject, Put, UseGuards } from "@nestjs/common";
import {
Body,
Controller,
Delete,
Get,
Inject,
Put,
Req,
UseGuards,
} from "@nestjs/common";
import { ProjectService } from "./project.service";
import { ApiTokenGuard } from "src/api/guards/api-token.guard";
import { AdminGuard } from "src/api/guards/admin.guard";
import { ProjectSettingService } from "./settings/project.setting.service";
@Controller("project")
@UseGuards(ApiTokenGuard)
export class ProjectController {
constructor(
@Inject(ProjectService)
private readonly projectService: ProjectService
private readonly projectService: ProjectService,
@Inject(ProjectSettingService)
private readonly projectSettingService: ProjectSettingService
) {}
@Put("create")
@ -21,4 +33,29 @@ export class ProjectController {
createProjectWithoutDB(@Body() body: { name: string }) {
return this.projectService.create(body.name, false);
}
@Put("settings/create")
createSetting(
@Body() body: { key: string; value: string },
@Req() req: Request & { apiToken: { id: string } }
) {
return this.projectSettingService.create(
req.apiToken.id,
body.key,
body.value
);
}
@Delete("settings/delete")
deleteSetting(
@Body() body: { key: string },
@Req() req: Request & { apiToken: { id: string } }
) {
return this.projectSettingService.delete(req.apiToken.id, body.key);
}
@Get("settings")
getAllSettings(@Req() req: Request & { apiToken: { id: string } }) {
return this.projectSettingService.getAll(req.apiToken.id);
}
}