feat: secure custom field value routing

This commit is contained in:
MatthieuTD
2025-09-22 10:20:49 +02:00
parent b6ca9ae54b
commit c8cc15c907
4 changed files with 274 additions and 22 deletions

View File

@@ -1,6 +1,11 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { CustomFieldsService } from './custom-fields.service';
import { CreateCustomFieldValueDto, UpdateCustomFieldValueDto } from '../shared/dto/custom-field.dto';
import {
CreateCustomFieldValueDto,
UpdateCustomFieldValueDto,
CustomFieldEntityParamsDto,
UpsertCustomFieldValueDto,
} from '../shared/dto/custom-field.dto';
@Controller('custom-fields')
export class CustomFieldsController {
@@ -12,11 +17,11 @@ export class CustomFieldsController {
}
@Get('values/:entityType/:entityId')
findCustomFieldValuesByEntity(
@Param('entityType') entityType: string,
@Param('entityId') entityId: string,
) {
return this.customFieldsService.findCustomFieldValuesByEntity(entityType, entityId);
findCustomFieldValuesByEntity(@Param() params: CustomFieldEntityParamsDto) {
return this.customFieldsService.findCustomFieldValuesByEntity(
params.entityType,
params.entityId,
);
}
@Get('values/:id')
@@ -38,12 +43,7 @@ export class CustomFieldsController {
}
@Post('values/upsert')
upsertCustomFieldValue(@Body() body: {
customFieldId: string;
entityType: string;
entityId: string;
value: string;
}) {
upsertCustomFieldValue(@Body() body: UpsertCustomFieldValueDto) {
return this.customFieldsService.upsertCustomFieldValue(
body.customFieldId,
body.entityType,
@@ -51,4 +51,4 @@ export class CustomFieldsController {
body.value,
);
}
}
}