Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

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

jubnld572b1ec8d4c
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) {}