feat(server): adopt zod DTOs for the share-link body contract

This commit is contained in:
jubnl
2026-07-26 21:25:34 +02:00
parent 72c3edda1a
commit d572b1ec8d
3 changed files with 12 additions and 2 deletions
@@ -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',
+2 -1
View File
@@ -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);
+10
View File
@@ -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) {}