@ts-rest/nest
Advanced tools
Comparing version 3.11.2 to 3.12.0
19
index.js
@@ -0,3 +1,3 @@ | ||
import { getRouteResponses, parseJsonQueryObject, checkZodSchema } from '@ts-rest/core'; | ||
import { createParamDecorator, BadRequestException, Injectable, applyDecorators, SetMetadata, UseInterceptors, Put, Patch, Post, Get, Delete } from '@nestjs/common'; | ||
import { checkZodSchema } from '@ts-rest/core'; | ||
import { map } from 'rxjs'; | ||
@@ -9,2 +9,3 @@ | ||
routeShapes: {}, | ||
responseShapes: getRouteResponses(router), | ||
route: router, | ||
@@ -36,2 +37,9 @@ }; | ||
const JsonQuerySymbol = Symbol('JsonQuery'); | ||
const JsonQuery = (jsonQuery = true) => { | ||
return (target) => { | ||
Reflect.defineMetadata(JsonQuerySymbol, jsonQuery, target); | ||
}; | ||
}; | ||
const tsRestAppRouteMetadataKey = Symbol('ts-rest-app-route'); | ||
@@ -45,3 +53,8 @@ const ApiDecorator = createParamDecorator((_, ctx) => { | ||
} | ||
const queryResult = checkZodSchema(req.query, appRoute.query); | ||
const isJsonQuery = !!(Reflect.getMetadata(JsonQuerySymbol, ctx.getHandler()) || | ||
Reflect.getMetadata(JsonQuerySymbol, ctx.getClass())); | ||
const query = isJsonQuery | ||
? parseJsonQueryObject(req.query) | ||
: req.query; | ||
const queryResult = checkZodSchema(query, appRoute.query); | ||
if (!queryResult.success) { | ||
@@ -102,2 +115,2 @@ throw new BadRequestException(queryResult.error); | ||
export { Api, ApiDecorator, ApiRouteInterceptor, initNestServer }; | ||
export { Api, ApiDecorator, ApiRouteInterceptor, JsonQuery, JsonQuerySymbol, initNestServer }; |
{ | ||
"name": "@ts-rest/nest", | ||
"version": "3.11.2", | ||
"version": "3.12.0", | ||
"description": "Nest server integration for @ts-rest", | ||
@@ -34,3 +34,3 @@ "license": "MIT", | ||
"zod": "3.x.x", | ||
"@ts-rest/core": "3.11.2" | ||
"@ts-rest/core": "3.12.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
export * from './lib/ts-rest-nest'; | ||
export * from './lib/api.decorator'; | ||
export * from './lib/json-query.decorator'; |
@@ -15,4 +15,5 @@ import { AppRoute, AppRouter, ApiRouteResponse, Without } from '@ts-rest/core'; | ||
routeShapes: AppRouteShape<T>; | ||
responseShapes: { [K in keyof T]: T[K] extends AppRoute ? import("@ts-rest/core").ApiResponseForRoute<T[K]> : "not a route"; }; | ||
route: T; | ||
}; | ||
export {}; |
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
14002
8
252