New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trpc/server

Package Overview
Dependencies
Maintainers
3
Versions
1125
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.740 to 11.0.0-rc.741

8

dist/adapters/node-http/types.d.ts

@@ -65,7 +65,11 @@ /**

};
export type NodeHTTPRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = {
export type NodeHTTPRequestHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
req: TRequest;
res: TResponse;
/**
* The tRPC path to handle requests for
* @example 'post.all'
*/
path: string;
} & NodeHTTPHandlerOptions<TRouter, TRequest, TResponse>;
};
export type NodeHTTPCreateContextFnOptions<TRequest, TResponse> = {

@@ -72,0 +76,0 @@ req: TRequest;

@@ -13,4 +13,15 @@ /**

import { type AnyRouter } from '../@trpc/server';
import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from './node-http';
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
import type { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPResponse } from './node-http';
type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
/**
* The base path to handle requests for.
* This will be sliced from the beginning of the request path
* (Do not miss including the trailing slash)
* @default '/'
* @example '/trpc/'
* @example '/trpc/api/'
*/
basePath?: string;
};
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;

@@ -22,5 +33,6 @@ /**

export declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = NodeHTTPHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
export declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
export {};
//# sourceMappingURL=standalone.d.ts.map

@@ -12,2 +12,4 @@ 'use strict';

function createHandler(opts) {
const basePath = opts.basePath ?? '/';
const sliceLength = basePath.length;
return (req, res)=>{

@@ -17,5 +19,4 @@ let path = '';

const url = incomingMessageToRequest.createURL(req);
// get procedure path and remove the leading slash
// /procedure -> procedure
path = url.pathname.slice(1);
// get procedure(s) path and remove the leading slash
path = url.pathname.slice(sliceLength);
await nodeHTTPRequestHandler.nodeHTTPRequestHandler({

@@ -22,0 +23,0 @@ ...opts,

{
"bundleSize": 194829,
"bundleOrigSize": 225251,
"bundleReduction": 13.51,
"bundleSize": 194887,
"bundleOrigSize": 225774,
"bundleReduction": 13.68,
"modules": [

@@ -17,3 +17,3 @@ {

],
"percent": 10.8,
"percent": 10.79,
"reduction": 0

@@ -110,3 +110,3 @@ },

],
"percent": 3.99,
"percent": 3.98,
"reduction": 0

@@ -260,3 +260,3 @@ },

],
"percent": 1.67,
"percent": 1.66,
"reduction": 22.52

@@ -357,3 +357,2 @@ },

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

@@ -363,2 +362,3 @@ "/src/unstable-core-do-not-import/transformer.ts",

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

@@ -640,4 +640,4 @@ "/src/unstable-core-do-not-import/http/isAbortError.ts",

"id": "/src/adapters/standalone.ts",
"size": 900,
"origSize": 2580,
"size": 958,
"origSize": 3103,
"renderedExports": [

@@ -650,4 +650,4 @@ "createHTTPHandler",

"dependents": [],
"percent": 0.46,
"reduction": 65.12
"percent": 0.49,
"reduction": 69.13
},

@@ -875,5 +875,5 @@ {

{
"id": "/src/rpc.ts",
"id": "/src/index.ts",
"size": 0,
"origSize": 36,
"origSize": 32,
"renderedExports": [],

@@ -886,5 +886,5 @@ "removedExports": [],

{
"id": "/src/index.ts",
"id": "/src/shared.ts",
"size": 0,
"origSize": 32,
"origSize": 653,
"renderedExports": [],

@@ -897,5 +897,5 @@ "removedExports": [],

{
"id": "/src/shared.ts",
"id": "/src/rpc.ts",
"size": 0,
"origSize": 653,
"origSize": 36,
"renderedExports": [],

@@ -915,5 +915,5 @@ "removedExports": [],

"/src/adapters/express.ts",
"/src/adapters/ws.ts",
"/src/adapters/standalone.ts",
"/src/adapters/next.ts",
"/src/adapters/ws.ts",
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",

@@ -949,5 +949,5 @@ "/src/adapters/next-app-dir/nextAppDirCaller.ts",

{
"id": "/src/adapters/fastify/index.ts",
"id": "/src/adapters/fetch/index.ts",
"size": 0,
"origSize": 78,
"origSize": 64,
"renderedExports": [],

@@ -960,5 +960,5 @@ "removedExports": [],

{
"id": "/src/adapters/fetch/index.ts",
"id": "/src/adapters/fastify/index.ts",
"size": 0,
"origSize": 64,
"origSize": 78,
"renderedExports": [],

@@ -978,5 +978,5 @@ "removedExports": [],

"/src/adapters/express.ts",
"/src/adapters/ws.ts",
"/src/adapters/standalone.ts",
"/src/adapters/next.ts",
"/src/adapters/ws.ts",
"/src/adapters/fastify/fastifyRequestHandler.ts"

@@ -983,0 +983,0 @@ ],

{
"name": "@trpc/server",
"version": "11.0.0-rc.740+df313f4ad",
"version": "11.0.0-rc.741+caed91ee7",
"description": "The tRPC server library",

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

},
"gitHead": "df313f4ade37202545103974aeeb4975e9c032cb"
"gitHead": "caed91ee782f78ada6c8c0c82e2d9d2ff474f555"
}

@@ -111,7 +111,11 @@ /**

TResponse extends NodeHTTPResponse,
> = {
> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
req: TRequest;
res: TResponse;
/**
* The tRPC path to handle requests for
* @example 'post.all'
*/
path: string;
} & NodeHTTPHandlerOptions<TRouter, TRequest, TResponse>;
};

@@ -118,0 +122,0 @@ export type NodeHTTPCreateContextFnOptions<TRequest, TResponse> = {

@@ -30,5 +30,21 @@ /**

type StandaloneHandlerOptions<
TRouter extends AnyRouter,
TRequest extends NodeHTTPRequest,
TResponse extends NodeHTTPResponse,
> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
/**
* The base path to handle requests for.
* This will be sliced from the beginning of the request path
* (Do not miss including the trailing slash)
* @default '/'
* @example '/trpc/'
* @example '/trpc/api/'
*/
basePath?: string;
};
// --- http1 ---
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> =
NodeHTTPHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;

@@ -45,12 +61,15 @@ export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<

>(
opts: NodeHTTPHandlerOptions<TRouter, TRequest, TResponse>,
opts: StandaloneHandlerOptions<TRouter, TRequest, TResponse>,
): (req: TRequest, res: TResponse) => void {
const basePath = opts.basePath ?? '/';
const sliceLength = basePath.length;
return (req, res) => {
let path = '';
run(async () => {
const url = createURL(req);
// get procedure path and remove the leading slash
// /procedure -> procedure
path = url.pathname.slice(1);
// get procedure(s) path and remove the leading slash
path = url.pathname.slice(sliceLength);

@@ -91,3 +110,3 @@ await nodeHTTPRequestHandler({

export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> =
NodeHTTPHandlerOptions<
StandaloneHandlerOptions<
TRouter,

@@ -94,0 +113,0 @@ http2.Http2ServerRequest,

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