@trpc/server 11.15.2-canary.2 → 11.15.2-canary.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@trpc/server",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "11.15.2-canary.2+bdf2c6532",
5
+ "version": "11.15.2-canary.3+c4b1d7458",
6
6
  "description": "The tRPC server library",
7
7
  "author": "KATT",
8
8
  "license": "MIT",
@@ -238,5 +238,5 @@
238
238
  "bin": {
239
239
  "intent": "./bin/intent.js"
240
240
  },
241
- "gitHead": "bdf2c6532e68afdccec30c50bfe44f94669bd865"
241
+ "gitHead": "c4b1d7458ec869f6c51469f7fcd84b517d53ffae"
242
242
  }
@@ -9,7 +9,7 @@ description: >
9
9
  context for context creation.
10
10
  type: core
11
11
  library: trpc
12
- library_version: '11.14.0'
12
+ library_version: '11.15.1'
13
13
  requires:
14
14
  - server-setup
15
15
  sources:
@@ -122,6 +122,21 @@ export const appRouter = t.router({
122
122
 
123
123
  Pair with `httpBatchStreamLink` on the client for streamed responses.
124
124
 
125
+ ### Limiting batch size with maxBatchSize
126
+
127
+ ```ts
128
+ import { awsLambdaRequestHandler } from '@trpc/server/adapters/aws-lambda';
129
+ import { appRouter } from './router';
130
+
131
+ export const handler = awsLambdaRequestHandler({
132
+ router: appRouter,
133
+ createContext,
134
+ maxBatchSize: 10,
135
+ });
136
+ ```
137
+
138
+ Requests batching more than `maxBatchSize` operations are rejected with a `400 Bad Request` error. Set `maxItems` on your client's `httpBatchLink` to the same value to avoid exceeding the limit.
139
+
125
140
  ## Common Mistakes
126
141
 
127
142
  ### HIGH Using httpBatchLink with per-procedure API Gateway resources
@@ -7,7 +7,7 @@ description: >
7
7
  Avoid global express.json() conflicting with tRPC body parsing for FormData.
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources:
@@ -107,6 +107,30 @@ app.use(
107
107
  app.listen(4000);
108
108
  ```
109
109
 
110
+ ### Limiting batch size with maxBatchSize
111
+
112
+ ```ts
113
+ import * as trpcExpress from '@trpc/server/adapters/express';
114
+ import express from 'express';
115
+ import { createContext } from './context';
116
+ import { appRouter } from './router';
117
+
118
+ const app = express();
119
+
120
+ app.use(
121
+ '/trpc',
122
+ trpcExpress.createExpressMiddleware({
123
+ router: appRouter,
124
+ createContext,
125
+ maxBatchSize: 10,
126
+ }),
127
+ );
128
+
129
+ app.listen(4000);
130
+ ```
131
+
132
+ Requests batching more than `maxBatchSize` operations are rejected with a `400 Bad Request` error. Set `maxItems` on your client's `httpBatchLink` to the same value to avoid exceeding the limit.
133
+
110
134
  ## Common Mistakes
111
135
 
112
136
  ### HIGH Global express.json() consuming tRPC request body
@@ -9,7 +9,7 @@ description: >
9
9
  CreateFastifyContextOptions provides req, res.
10
10
  type: core
11
11
  library: trpc
12
- library_version: '11.14.0'
12
+ library_version: '11.15.1'
13
13
  requires:
14
14
  - server-setup
15
15
  sources:
@@ -132,6 +132,21 @@ server.register(fastifyTRPCPlugin, {
132
132
 
133
133
  Due to Fastify plugin type inference limitations, use `satisfies FastifyTRPCPluginOptions<AppRouter>['trpcOptions']` to get correct types on `onError` and other callbacks.
134
134
 
135
+ ### Limiting batch size with maxBatchSize
136
+
137
+ ```ts
138
+ server.register(fastifyTRPCPlugin, {
139
+ prefix: '/trpc',
140
+ trpcOptions: {
141
+ router: appRouter,
142
+ createContext,
143
+ maxBatchSize: 10,
144
+ } satisfies FastifyTRPCPluginOptions<AppRouter>['trpcOptions'],
145
+ });
146
+ ```
147
+
148
+ Requests batching more than `maxBatchSize` operations are rejected with a `400 Bad Request` error. Set `maxItems` on your client's `httpBatchLink` to the same value to avoid exceeding the limit.
149
+
135
150
  ## Common Mistakes
136
151
 
137
152
  ### HIGH Registering @fastify/websocket after tRPC plugin
@@ -8,7 +8,7 @@ description: >
8
8
  must match the URL path prefix where the handler is mounted.
9
9
  type: core
10
10
  library: trpc
11
- library_version: '11.14.0'
11
+ library_version: '11.15.1'
12
12
  requires:
13
13
  - server-setup
14
14
  sources:
@@ -135,6 +135,28 @@ Deno.serve((request) => {
135
135
  });
136
136
  ```
137
137
 
138
+ ### Limiting batch size with maxBatchSize
139
+
140
+ ```ts
141
+ import { fetchRequestHandler } from '@trpc/server/adapters/fetch';
142
+ import { createContext } from './context';
143
+ import { appRouter } from './router';
144
+
145
+ export default {
146
+ async fetch(request: Request): Promise<Response> {
147
+ return fetchRequestHandler({
148
+ endpoint: '/trpc',
149
+ req: request,
150
+ router: appRouter,
151
+ createContext,
152
+ maxBatchSize: 10,
153
+ });
154
+ },
155
+ };
156
+ ```
157
+
158
+ Requests batching more than `maxBatchSize` operations are rejected with a `400 Bad Request` error. Set `maxItems` on your client's `httpBatchLink` to the same value to avoid exceeding the limit.
159
+
138
160
  ## Common Mistakes
139
161
 
140
162
  ### HIGH Mismatched endpoint path in fetchRequestHandler
@@ -8,7 +8,7 @@ description: >
8
8
  provides req and res for context creation.
9
9
  type: core
10
10
  library: trpc
11
- library_version: '11.14.0'
11
+ library_version: '11.15.1'
12
12
  requires:
13
13
  - server-setup
14
14
  sources:
@@ -143,6 +143,20 @@ const server = http2.createSecureServer(
143
143
  server.listen(3001);
144
144
  ```
145
145
 
146
+ ### Limiting batch size with maxBatchSize
147
+
148
+ ```ts
149
+ import { createHTTPServer } from '@trpc/server/adapters/standalone';
150
+ import { appRouter } from './router';
151
+
152
+ createHTTPServer({
153
+ router: appRouter,
154
+ maxBatchSize: 10,
155
+ }).listen(3000);
156
+ ```
157
+
158
+ Requests batching more than `maxBatchSize` operations are rejected with a `400 Bad Request` error. Set `maxItems` on your client's `httpBatchLink` to the same value to avoid exceeding the limit.
159
+
146
160
  ## Common Mistakes
147
161
 
148
162
  ### HIGH No CORS configuration for cross-origin requests
@@ -8,7 +8,7 @@ description: >
8
8
  or EventSource polyfill custom headers.
9
9
  type: composition
10
10
  library: trpc
11
- library_version: '11.14.0'
11
+ library_version: '11.15.1'
12
12
  requires:
13
13
  - server-setup
14
14
  - middlewares
@@ -7,7 +7,7 @@ description: >
7
7
  Avoid caching mutations, errors, and authenticated responses.
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources:
@@ -7,7 +7,7 @@ description: >
7
7
  to HTTP status codes with getHTTPStatusCodeFromError().
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources:
@@ -7,7 +7,7 @@ description: >
7
7
  with getRawInput(). Logging, timing, OTEL tracing patterns.
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources:
@@ -7,7 +7,7 @@ description: >
7
7
  @trpc/client. FormData and binary inputs only work with mutations (POST).
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  - links
@@ -7,7 +7,7 @@ description: >
7
7
  lazy-load routers with lazy().
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires: []
12
12
  sources:
13
13
  - 'trpc/trpc:www/docs/server/overview.md'
@@ -7,7 +7,7 @@ description: >
7
7
  getHTTPStatusCodeFromError(). Error handling via onError option.
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources:
@@ -9,7 +9,7 @@ description: >
9
9
  initTRPC instance. Each service runs its own standalone/Express/Fastify server.
10
10
  type: composition
11
11
  library: trpc
12
- library_version: '11.14.0'
12
+ library_version: '11.15.1'
13
13
  requires:
14
14
  - server-setup
15
15
  - client-setup
@@ -10,7 +10,7 @@ description: >
10
10
  via opts.signal for cleanup. splitLink to route subscriptions.
11
11
  type: core
12
12
  library: trpc
13
- library_version: '11.14.0'
13
+ library_version: '11.15.1'
14
14
  requires:
15
15
  - server-setup
16
16
  - links
@@ -6,7 +6,7 @@ description: >
6
6
  Next.js, links, middleware, validators, error handling, caching, FormData.
7
7
  type: core
8
8
  library: trpc
9
- library_version: '11.14.0'
9
+ library_version: '11.15.1'
10
10
  requires: []
11
11
  sources:
12
12
  - 'trpc/trpc:www/docs/main/introduction.mdx'
@@ -7,7 +7,7 @@ description: >
7
7
  support. Output validation returns INTERNAL_SERVER_ERROR on failure.
8
8
  type: core
9
9
  library: trpc
10
- library_version: '11.14.0'
10
+ library_version: '11.15.1'
11
11
  requires:
12
12
  - server-setup
13
13
  sources: