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

@trpc/server

Package Overview
Dependencies
Maintainers
0
Versions
1076
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trpc/server - npm Package Compare versions

Comparing version 11.0.0-rc.677 to 11.0.0-rc.678

11

dist/adapters/node-http/incomingMessageToRequest.d.ts
import type * as http from 'http';
export interface IncomingMessageWithBody extends http.IncomingMessage {
export interface UniversalIncomingMessage extends Omit<http.IncomingMessage, 'socket'> {
/**

@@ -7,8 +7,13 @@ * Many adapters will add a `body` property to the incoming message and pre-parse the body

body?: unknown;
/**
* Socket is not always available in all deployments, so we need to make it optional
* @see https://github.com/trpc/trpc/issues/6341
*/
socket?: http.IncomingMessage['socket'];
}
export declare function createURL(req: http.IncomingMessage): URL;
export declare function createURL(req: UniversalIncomingMessage): URL;
/**
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
*/
export declare function incomingMessageToRequest(req: http.IncomingMessage, res: http.ServerResponse, opts: {
export declare function incomingMessageToRequest(req: UniversalIncomingMessage, res: http.ServerResponse, opts: {
/**

@@ -15,0 +20,0 @@ * Max body size in bytes. If the body is larger than this, the request will be aborted

@@ -11,10 +11,12 @@ 'use strict';

if ('body' in req) {
if (req.body === undefined) {
// If body property exists but is undefined, return undefined
return undefined;
}
// If the body is already a string, return it directly
if (typeof req.body === 'string') {
return req.body;
} else if (req.body !== undefined) {
return JSON.stringify(req.body);
}
// If body property exists but is undefined, return undefined
return undefined;
// If body exists but isn't a string, stringify it as JSON
return JSON.stringify(req.body);
}

@@ -92,3 +94,3 @@ let size = 0;

res.off('close', onAbort);
req.socket.off('end', onAbort);
req.socket?.off('end', onAbort);
// abort the request

@@ -98,3 +100,3 @@ ac.abort();

res.once('close', onAbort);
req.socket.once('end', onAbort);
req.socket?.once('end', onAbort);
// Get host from either regular header or HTTP/2 pseudo-header

@@ -101,0 +103,0 @@ const url = createURL(req);

{
"bundleSize": 186969,
"bundleOrigSize": 219149,
"bundleReduction": 14.68,
"bundleSize": 187045,
"bundleOrigSize": 219372,
"bundleReduction": 14.74,
"modules": [

@@ -50,3 +50,3 @@ {

],
"percent": 10.77,
"percent": 10.76,
"reduction": 0

@@ -68,3 +68,3 @@ },

],
"percent": 6.65,
"percent": 6.64,
"reduction": 0

@@ -163,3 +163,3 @@ },

],
"percent": 2.9,
"percent": 2.89,
"reduction": 11.51

@@ -199,6 +199,22 @@ },

],
"percent": 2.38,
"percent": 2.37,
"reduction": 0
},
{
"id": "/src/adapters/node-http/incomingMessageToRequest.ts",
"size": 3914,
"origSize": 4578,
"renderedExports": [
"createURL",
"incomingMessageToRequest"
],
"removedExports": [],
"dependents": [
"/src/adapters/node-http/index.ts",
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
],
"percent": 2.09,
"reduction": 14.5
},
{
"id": "/src/observable/operators.ts",

@@ -222,18 +238,2 @@ "size": 3910,

{
"id": "/src/adapters/node-http/incomingMessageToRequest.ts",
"size": 3838,
"origSize": 4355,
"renderedExports": [
"createURL",
"incomingMessageToRequest"
],
"removedExports": [],
"dependents": [
"/src/adapters/node-http/index.ts",
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
],
"percent": 2.05,
"reduction": 11.87
},
{
"id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",

@@ -249,3 +249,3 @@ "size": 3244,

],
"percent": 1.74,
"percent": 1.73,
"reduction": 22.52

@@ -281,5 +281,5 @@ },

"/src/unstable-core-do-not-import.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/initTRPC.ts",
"/src/unstable-core-do-not-import/router.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
"/src/unstable-core-do-not-import/router.ts"
],

@@ -344,2 +344,5 @@ "percent": 1.46,

"/src/unstable-core-do-not-import.ts",
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/error/TRPCError.ts",

@@ -349,5 +352,2 @@ "/src/unstable-core-do-not-import/transformer.ts",

"/src/unstable-core-do-not-import/router.ts",
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",

@@ -375,6 +375,6 @@ "/src/unstable-core-do-not-import/http/contentType.ts",

"/src/unstable-core-do-not-import.ts",
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/middleware.ts",
"/src/unstable-core-do-not-import/router.ts",
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/http/contentType.ts",

@@ -446,4 +446,4 @@ "/src/unstable-core-do-not-import/procedureBuilder.ts",

"/src/unstable-core-do-not-import.ts",
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
],

@@ -835,8 +835,10 @@ "percent": 1.12,

{
"id": "/src/index.ts",
"id": "/src/http.ts",
"size": 0,
"origSize": 32,
"origSize": 37,
"renderedExports": [],
"removedExports": [],
"dependents": [],
"dependents": [
"/src/adapters/ws.ts"
],
"percent": 0,

@@ -846,10 +848,8 @@ "reduction": 100

{
"id": "/src/http.ts",
"id": "/src/index.ts",
"size": 0,
"origSize": 37,
"origSize": 32,
"renderedExports": [],
"removedExports": [],
"dependents": [
"/src/adapters/ws.ts"
],
"dependents": [],
"percent": 0,

@@ -885,4 +885,4 @@ "reduction": 100

"dependents": [
"/src/adapters/express.ts",
"/src/adapters/next.ts",
"/src/adapters/express.ts",
"/src/adapters/standalone.ts",

@@ -946,4 +946,4 @@ "/src/adapters/ws.ts",

"dependents": [
"/src/adapters/express.ts",
"/src/adapters/next.ts",
"/src/adapters/express.ts",
"/src/adapters/standalone.ts",

@@ -950,0 +950,0 @@ "/src/adapters/ws.ts",

{
"name": "@trpc/server",
"version": "11.0.0-rc.677+1032f4880",
"version": "11.0.0-rc.678+29a2f0d18",
"description": "The tRPC server library",

@@ -155,3 +155,3 @@ "author": "KATT",

},
"gitHead": "1032f48805c74e814cad8aba2ba9811e914b7b85"
"gitHead": "29a2f0d1802a4fe286ae56715ac1a06315f8f858"
}

@@ -22,4 +22,4 @@ /**

incomingMessageToRequest,
type IncomingMessageWithBody,
type NodeHTTPCreateContextOption,
type UniversalIncomingMessage,
} from '../node-http';

@@ -58,3 +58,3 @@

const incomingMessage = opts.req.raw as IncomingMessageWithBody;
const incomingMessage: UniversalIncomingMessage = opts.req.raw;

@@ -61,0 +61,0 @@ // monkey-path body to the IncomingMessage

import type * as http from 'http';
import { TRPCError } from '../../@trpc/server';
export interface IncomingMessageWithBody extends http.IncomingMessage {
export interface UniversalIncomingMessage
extends Omit<http.IncomingMessage, 'socket'> {
/**

@@ -9,6 +10,11 @@ * Many adapters will add a `body` property to the incoming message and pre-parse the body

body?: unknown;
/**
* Socket is not always available in all deployments, so we need to make it optional
* @see https://github.com/trpc/trpc/issues/6341
*/
socket?: http.IncomingMessage['socket'];
}
function createBody(
req: http.IncomingMessage,
req: UniversalIncomingMessage,
opts: {

@@ -23,2 +29,6 @@ /**

if ('body' in req) {
if (req.body === undefined) {
// If body property exists but is undefined, return undefined
return undefined;
}
// If the body is already a string, return it directly

@@ -29,7 +39,3 @@ if (typeof req.body === 'string') {

// If body exists but isn't a string, stringify it as JSON
else if (req.body !== undefined) {
return JSON.stringify(req.body);
}
// If body property exists but is undefined, return undefined
return undefined;
return JSON.stringify(req.body);
}

@@ -77,3 +83,3 @@ let size = 0;

}
export function createURL(req: http.IncomingMessage): URL {
export function createURL(req: UniversalIncomingMessage): URL {
try {

@@ -124,3 +130,3 @@ const protocol =

export function incomingMessageToRequest(
req: http.IncomingMessage,
req: UniversalIncomingMessage,
res: http.ServerResponse,

@@ -138,3 +144,3 @@ opts: {

res.off('close', onAbort);
req.socket.off('end', onAbort);
req.socket?.off('end', onAbort);

@@ -146,3 +152,3 @@ // abort the request

res.once('close', onAbort);
req.socket.once('end', onAbort);
req.socket?.once('end', onAbort);

@@ -149,0 +155,0 @@ // Get host from either regular header or HTTP/2 pseudo-header

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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