mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
feat(server): adopt zod DTOs for the share-link body contract
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {}
|
||||
Reference in New Issue
Block a user