@ts-rest/nest
Advanced tools
Comparing version 3.19.5 to 3.20.0
21
index.js
import { SetMetadata, Injectable, UseInterceptors, applyDecorators, Put, Patch, Post, Get, Delete, createParamDecorator, BadRequestException } from '@nestjs/common'; | ||
import { map } from 'rxjs'; | ||
import { isAppRouteResponse, validateResponse, parseJsonQueryObject, checkZodSchema, zodErrorResponse } from '@ts-rest/core'; | ||
import { isAppRouteResponse, validateResponse, checkZodSchema, zodErrorResponse, parseJsonQueryObject } from '@ts-rest/core'; | ||
import { Reflector } from '@nestjs/core'; | ||
@@ -127,2 +127,14 @@ | ||
} | ||
const pathParamsResult = checkZodSchema(req.params, appRoute.pathParams, { | ||
passThroughExtraKeys: true, | ||
}); | ||
if (!pathParamsResult.success) { | ||
throw new BadRequestException(zodErrorResponse(pathParamsResult.error)); | ||
} | ||
const headersResult = checkZodSchema(req.headers, appRoute.headers, { | ||
passThroughExtraKeys: true, | ||
}); | ||
if (!headersResult.success) { | ||
throw new BadRequestException(zodErrorResponse(headersResult.error)); | ||
} | ||
const isJsonQuery = !!((_a = Reflect.getMetadata(JsonQuerySymbol, ctx.getHandler())) !== null && _a !== void 0 ? _a : Reflect.getMetadata(JsonQuerySymbol, ctx.getClass())); | ||
@@ -140,8 +152,2 @@ const query = isJsonQuery | ||
} | ||
const pathParamsResult = checkZodSchema(req.params, appRoute.pathParams, { | ||
passThroughExtraKeys: true, | ||
}); | ||
if (!pathParamsResult.success) { | ||
throw new BadRequestException(zodErrorResponse(pathParamsResult.error)); | ||
} | ||
return { | ||
@@ -151,2 +157,3 @@ query: queryResult.data, | ||
body: bodyResult.data, | ||
headers: headersResult.data, | ||
}; | ||
@@ -153,0 +160,0 @@ }); |
{ | ||
"name": "@ts-rest/nest", | ||
"version": "3.19.5", | ||
"version": "3.20.0", | ||
"description": "Nest server integration for @ts-rest", | ||
@@ -27,3 +27,3 @@ "license": "MIT", | ||
"zod": "^3.0.0", | ||
"@ts-rest/core": "3.19.5" | ||
"@ts-rest/core": "3.20.0" | ||
}, | ||
@@ -30,0 +30,0 @@ "peerDependenciesMeta": { |
@@ -1,2 +0,3 @@ | ||
import { AppRoute, AppRouteMutation, PathParamsWithCustomValidators, Without, ZodInferOrType } from '@ts-rest/core'; | ||
import { AppRoute, AppRouteMutation, LowercaseKeys, PathParamsWithCustomValidators, Without, ZodInferOrType } from '@ts-rest/core'; | ||
import type { Request } from 'express-serve-static-core'; | ||
type BodyWithoutFileIfMultiPart<T extends AppRouteMutation> = T['contentType'] extends 'multipart/form-data' ? Without<ZodInferOrType<T['body']>, File> : ZodInferOrType<T['body']>; | ||
@@ -7,2 +8,3 @@ export type TsRestRequestShape<TRoute extends AppRoute> = Without<{ | ||
query: ZodInferOrType<TRoute['query']>; | ||
headers: LowercaseKeys<ZodInferOrType<TRoute['headers']>> & Request['headers']; | ||
}, never>; | ||
@@ -9,0 +11,0 @@ /** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26961
400