Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-rest/nest

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-rest/nest - npm Package Compare versions

Comparing version 3.6.1 to 3.7.0

28

index.js
import { createParamDecorator, BadRequestException, Injectable, HttpException, applyDecorators, UseInterceptors, Put, Patch, Post, Get, Delete } from '@nestjs/common';
import { getPathParamsFromUrl, checkQuerySchema, checkBodySchema } from '@ts-rest/core';
import { getPathParamsFromUrl, checkZodSchema } from '@ts-rest/core';
import { map } from 'rxjs';

@@ -47,5 +47,3 @@

};
const ApiDecorator = createParamDecorator(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(_, ctx) => {
const ApiDecorator = createParamDecorator((_, ctx) => {
const req = ctx.switchToHttp().getRequest();

@@ -58,15 +56,20 @@ const appRoute = req.appRoute;

const queryParams = getQueryParams(req.url);
const queryResult = checkQuerySchema(queryParams, appRoute);
if (queryResult.success === false) {
const queryResult = checkZodSchema(queryParams, appRoute.query);
if (!queryResult.success) {
throw new BadRequestException(queryResult.error);
}
const bodyResult = checkBodySchema(req.body, appRoute);
if (bodyResult.success === false) {
const bodyResult = checkZodSchema(req.body, appRoute.method === 'GET' ? null : appRoute.body);
if (!bodyResult.success) {
throw new BadRequestException(bodyResult.error);
}
const pathParamsResult = checkZodSchema(pathParams, appRoute.pathParams, {
passThroughExtraKeys: true,
});
if (!pathParamsResult.success) {
throw new BadRequestException(pathParamsResult.error);
}
return {
query: queryResult.body,
// @ts-expect-error because the decorator shape is any
params: pathParams,
body: bodyResult.body,
query: queryResult.data,
params: pathParamsResult.data,
body: bodyResult.data,
};

@@ -92,3 +95,2 @@ });

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
intercept(context, next) {

@@ -95,0 +97,0 @@ const req = context.switchToHttp().getRequest();

import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
import { AppRoute, AppRouteMutation, PathParams, Without, ZodInferOrType } from '@ts-rest/core';
import { AppRoute, AppRouteMutation, PathParamsWithCustomValidators, Without, ZodInferOrType } from '@ts-rest/core';
import { Observable } from 'rxjs';
declare type BodyWithoutFileIfMultiPart<T extends AppRouteMutation> = T['contentType'] extends 'multipart/form-data' ? Without<ZodInferOrType<T['body']>, File> : ZodInferOrType<T['body']>;
export declare type ApiDecoratorShape<TRoute extends AppRoute> = Without<{
params: PathParams<TRoute>;
params: PathParamsWithCustomValidators<TRoute>;
body: TRoute extends AppRouteMutation ? BodyWithoutFileIfMultiPart<TRoute> : never;

@@ -8,0 +8,0 @@ query: ZodInferOrType<TRoute['query']>;

{
"name": "@ts-rest/nest",
"version": "3.6.1",
"version": "3.7.0",
"description": "Nest server integration for @ts-rest",

@@ -34,3 +34,3 @@ "license": "MIT",

"zod": "3.x.x",
"@ts-rest/core": "3.6.1"
"@ts-rest/core": "3.7.0"
},

@@ -37,0 +37,0 @@ "module": "./index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc