From d572b1ec8d4c9be8eb08c61744b401a917c1b1c1 Mon Sep 17 00:00:00 2001 From: jubnl Date: Sun, 26 Jul 2026 21:25:34 +0200 Subject: [PATCH] feat(server): adopt zod DTOs for the share-link body contract --- server/src/nest/common/body-contract-allow-list.ts | 1 - server/src/nest/share/share.controller.ts | 3 ++- server/src/nest/share/share.dto.ts | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 server/src/nest/share/share.dto.ts diff --git a/server/src/nest/common/body-contract-allow-list.ts b/server/src/nest/common/body-contract-allow-list.ts index bd711e9f3..cd65117c5 100644 --- a/server/src/nest/common/body-contract-allow-list.ts +++ b/server/src/nest/common/body-contract-allow-list.ts @@ -139,7 +139,6 @@ export const BODY_CONTRACT_ALLOW_LIST: string[] = [ 'SynologyMemoriesController.test', 'TagsController.create', 'TagsController.update', - 'TripShareController.create', 'TripsController.addMember', 'TripsController.copy', 'TripsController.create', diff --git a/server/src/nest/share/share.controller.ts b/server/src/nest/share/share.controller.ts index 502d7e75a..dbdd7dbe2 100644 --- a/server/src/nest/share/share.controller.ts +++ b/server/src/nest/share/share.controller.ts @@ -3,6 +3,7 @@ import type { Response } from 'express'; import { createReadStream } from 'node:fs'; import type { User } from '../../types'; import { ShareService } from './share.service'; +import { ShareLinkDto } from './share.dto'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { CurrentUser } from '../auth/current-user.decorator'; @@ -32,7 +33,7 @@ export class TripShareController { create( @CurrentUser() user: User, @Param('tripId') tripId: string, - @Body() body: { share_map?: boolean; share_bookings?: boolean; share_packing?: boolean; share_budget?: boolean; share_collab?: boolean }, + @Body() body: ShareLinkDto, @Res({ passthrough: true }) res: Response, ) { this.requireManage(tripId, user); diff --git a/server/src/nest/share/share.dto.ts b/server/src/nest/share/share.dto.ts new file mode 100644 index 000000000..94609d05e --- /dev/null +++ b/server/src/nest/share/share.dto.ts @@ -0,0 +1,10 @@ +import { createZodDto } from 'nestjs-zod'; +import { shareLinkRequestSchema } from '@trek/shared'; + +/** + * Server-side createZodDto wrapper over the @trek/shared share-link contract. + * The global ZodValidationPipe (APP_PIPE in app.module.ts) validates any + * @Body() parameter typed with this class by metatype — the Zod schema in + * shared/ remains the single source of truth for the wire contract. + */ +export class ShareLinkDto extends createZodDto(shareLinkRequestSchema) {}