@trpc/server 11.0.0-next-beta.299 → 11.0.0-next-beta.302
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/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +10 -0
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +10 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +2 -5
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -5
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +0 -1
- package/dist/adapters/standalone.mjs +0 -1
- package/dist/bundle-analysis.json +77 -77
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.js +5 -3
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.mjs +5 -3
- package/dist/unstable-core-do-not-import/http/types.d.ts +17 -0
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +1 -0
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.js +1 -1
- package/dist/unstable-core-do-not-import/router.mjs +1 -1
- package/package.json +2 -2
- package/src/adapters/node-http/content-type/json/getPostBody.ts +15 -0
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +3 -6
- package/src/adapters/standalone.ts +0 -1
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +5 -2
- package/src/unstable-core-do-not-import/http/types.ts +17 -0
- package/src/unstable-core-do-not-import/router.ts +9 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAgDtB"}
|
|
@@ -8,6 +8,16 @@ require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
|
8
8
|
async function getPostBody(opts) {
|
|
9
9
|
const { req , maxBodySize =Infinity } = opts;
|
|
10
10
|
return new Promise((resolve)=>{
|
|
11
|
+
if (!req.headers['content-type']?.startsWith('application/json') && req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD') {
|
|
12
|
+
resolve({
|
|
13
|
+
ok: false,
|
|
14
|
+
error: new TRPCError.TRPCError({
|
|
15
|
+
code: 'BAD_REQUEST',
|
|
16
|
+
message: 'Invalid content-type header (expected application/json)'
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
11
21
|
if ('body' in req) {
|
|
12
22
|
resolve({
|
|
13
23
|
ok: true,
|
|
@@ -6,6 +6,16 @@ import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
|
6
6
|
async function getPostBody(opts) {
|
|
7
7
|
const { req , maxBodySize =Infinity } = opts;
|
|
8
8
|
return new Promise((resolve)=>{
|
|
9
|
+
if (!req.headers['content-type']?.startsWith('application/json') && req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD') {
|
|
10
|
+
resolve({
|
|
11
|
+
ok: false,
|
|
12
|
+
error: new TRPCError({
|
|
13
|
+
code: 'BAD_REQUEST',
|
|
14
|
+
message: 'Invalid content-type header (expected application/json)'
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
9
19
|
if ('body' in req) {
|
|
10
20
|
resolve({
|
|
11
21
|
ok: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBA2HlE"}
|
|
@@ -84,12 +84,9 @@ async function nodeHTTPRequestHandler(opts) {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
await resolveHTTPResponse.resolveHTTPResponse({
|
|
87
|
-
|
|
88
|
-
responseMeta: opts.responseMeta,
|
|
89
|
-
path: opts.path,
|
|
90
|
-
createContext,
|
|
91
|
-
router: opts.router,
|
|
87
|
+
...opts,
|
|
92
88
|
req,
|
|
89
|
+
createContext,
|
|
93
90
|
error: bodyResult.ok ? null : bodyResult.error,
|
|
94
91
|
preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
|
|
95
92
|
onError (o) {
|
|
@@ -82,12 +82,9 @@ async function nodeHTTPRequestHandler(opts) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
await resolveHTTPResponse({
|
|
85
|
-
|
|
86
|
-
responseMeta: opts.responseMeta,
|
|
87
|
-
path: opts.path,
|
|
88
|
-
createContext,
|
|
89
|
-
router: opts.router,
|
|
85
|
+
...opts,
|
|
90
86
|
req,
|
|
87
|
+
createContext,
|
|
91
88
|
error: bodyResult.ok ? null : bodyResult.error,
|
|
92
89
|
preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
|
|
93
90
|
onError (o) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CACnE,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,SAEpB,KAAK,eAAe,OAAO,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CACnE,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,SAEpB,KAAK,eAAe,OAAO,KAAK,cAAc,mBAelE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,wEAIxC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 37.
|
|
2
|
+
"bundleSize": 92734,
|
|
3
|
+
"bundleOrigSize": 147860,
|
|
4
|
+
"bundleReduction": 37.28,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/adapters/ws.ts",
|
|
@@ -14,25 +14,25 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 10.
|
|
17
|
+
"percent": 10.75,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"id": "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
22
|
-
"size":
|
|
23
|
-
"origSize":
|
|
22
|
+
"size": 9385,
|
|
23
|
+
"origSize": 11914,
|
|
24
24
|
"renderedExports": [
|
|
25
25
|
"resolveHTTPResponse"
|
|
26
26
|
],
|
|
27
27
|
"removedExports": [],
|
|
28
28
|
"dependents": [],
|
|
29
|
-
"percent": 10.
|
|
30
|
-
"reduction": 21.
|
|
29
|
+
"percent": 10.12,
|
|
30
|
+
"reduction": 21.23
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
34
|
-
"size":
|
|
35
|
-
"origSize":
|
|
34
|
+
"size": 6069,
|
|
35
|
+
"origSize": 9881,
|
|
36
36
|
"renderedExports": [
|
|
37
37
|
"createRouterFactory",
|
|
38
38
|
"callProcedure",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
46
46
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
47
47
|
],
|
|
48
|
-
"percent": 6.
|
|
49
|
-
"reduction": 38.
|
|
48
|
+
"percent": 6.54,
|
|
49
|
+
"reduction": 38.58
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 6.
|
|
64
|
+
"percent": 6.15,
|
|
65
65
|
"reduction": 58.57
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"dependents": [
|
|
78
78
|
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
79
79
|
],
|
|
80
|
-
"percent": 5.
|
|
80
|
+
"percent": 5.37,
|
|
81
81
|
"reduction": 36.77
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -91,13 +91,13 @@
|
|
|
91
91
|
],
|
|
92
92
|
"removedExports": [],
|
|
93
93
|
"dependents": [],
|
|
94
|
-
"percent": 4.
|
|
94
|
+
"percent": 4.77,
|
|
95
95
|
"reduction": 32.71
|
|
96
96
|
},
|
|
97
97
|
{
|
|
98
98
|
"id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
99
|
-
"size":
|
|
100
|
-
"origSize":
|
|
99
|
+
"size": 3933,
|
|
100
|
+
"origSize": 4550,
|
|
101
101
|
"renderedExports": [
|
|
102
102
|
"nodeHTTPRequestHandler"
|
|
103
103
|
],
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"dependents": [
|
|
106
106
|
"/src/adapters/node-http/index.ts"
|
|
107
107
|
],
|
|
108
|
-
"percent": 4.
|
|
109
|
-
"reduction":
|
|
108
|
+
"percent": 4.24,
|
|
109
|
+
"reduction": 13.56
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"id": "/src/adapters/fetch/fetchRequestHandler.ts",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"dependents": [
|
|
120
120
|
"/src/adapters/fetch/index.ts"
|
|
121
121
|
],
|
|
122
|
-
"percent": 3.
|
|
122
|
+
"percent": 3.83,
|
|
123
123
|
"reduction": 9.5
|
|
124
124
|
},
|
|
125
125
|
{
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"dependents": [
|
|
136
136
|
"/src/observable/index.ts"
|
|
137
137
|
],
|
|
138
|
-
"percent": 3.
|
|
138
|
+
"percent": 3.7,
|
|
139
139
|
"reduction": 5.43
|
|
140
140
|
},
|
|
141
141
|
{
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"dependents": [
|
|
155
155
|
"/src/adapters/aws-lambda/index.ts"
|
|
156
156
|
],
|
|
157
|
-
"percent": 3.
|
|
157
|
+
"percent": 3.57,
|
|
158
158
|
"reduction": 36.48
|
|
159
159
|
},
|
|
160
160
|
{
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"dependents": [
|
|
171
171
|
"/src/observable/index.ts"
|
|
172
172
|
],
|
|
173
|
-
"percent": 3.
|
|
173
|
+
"percent": 3.21,
|
|
174
174
|
"reduction": 0
|
|
175
175
|
},
|
|
176
176
|
{
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"/src/unstable-core-do-not-import/router.ts",
|
|
191
191
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
192
192
|
],
|
|
193
|
-
"percent": 2.
|
|
193
|
+
"percent": 2.96,
|
|
194
194
|
"reduction": 45.94
|
|
195
195
|
},
|
|
196
196
|
{
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"dependents": [
|
|
205
205
|
"/src/unstable-core-do-not-import.ts"
|
|
206
206
|
],
|
|
207
|
-
"percent": 2.
|
|
207
|
+
"percent": 2.94,
|
|
208
208
|
"reduction": 39.13
|
|
209
209
|
},
|
|
210
210
|
{
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
225
225
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 2.
|
|
227
|
+
"percent": 2.83,
|
|
228
228
|
"reduction": 55.5
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"/src/adapters/fastify/index.ts",
|
|
240
240
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.79,
|
|
243
243
|
"reduction": 35.33
|
|
244
244
|
},
|
|
245
245
|
{
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
],
|
|
252
252
|
"removedExports": [],
|
|
253
253
|
"dependents": [],
|
|
254
|
-
"percent": 2.
|
|
254
|
+
"percent": 2.74,
|
|
255
255
|
"reduction": 31.37
|
|
256
256
|
},
|
|
257
257
|
{
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
273
273
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
274
274
|
],
|
|
275
|
-
"percent": 1.
|
|
275
|
+
"percent": 1.87,
|
|
276
276
|
"reduction": 19.47
|
|
277
277
|
},
|
|
278
278
|
{
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
"dependents": [
|
|
287
287
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
|
|
288
288
|
],
|
|
289
|
-
"percent": 1.
|
|
289
|
+
"percent": 1.77,
|
|
290
290
|
"reduction": 34.79
|
|
291
291
|
},
|
|
292
292
|
{
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
"dependents": [
|
|
301
301
|
"/src/adapters/fastify/index.ts"
|
|
302
302
|
],
|
|
303
|
-
"percent": 1.
|
|
303
|
+
"percent": 1.73,
|
|
304
304
|
"reduction": 31.58
|
|
305
305
|
},
|
|
306
306
|
{
|
|
@@ -312,7 +312,7 @@
|
|
|
312
312
|
],
|
|
313
313
|
"removedExports": [],
|
|
314
314
|
"dependents": [],
|
|
315
|
-
"percent": 1.
|
|
315
|
+
"percent": 1.73,
|
|
316
316
|
"reduction": 29.12
|
|
317
317
|
},
|
|
318
318
|
{
|
|
@@ -324,9 +324,23 @@
|
|
|
324
324
|
],
|
|
325
325
|
"removedExports": [],
|
|
326
326
|
"dependents": [],
|
|
327
|
-
"percent": 1.
|
|
327
|
+
"percent": 1.7,
|
|
328
328
|
"reduction": 21.04
|
|
329
329
|
},
|
|
330
|
+
{
|
|
331
|
+
"id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
|
|
332
|
+
"size": 1562,
|
|
333
|
+
"origSize": 1547,
|
|
334
|
+
"renderedExports": [
|
|
335
|
+
"getPostBody"
|
|
336
|
+
],
|
|
337
|
+
"removedExports": [],
|
|
338
|
+
"dependents": [
|
|
339
|
+
"/src/adapters/node-http/content-type/json/index.ts"
|
|
340
|
+
],
|
|
341
|
+
"percent": 1.68,
|
|
342
|
+
"reduction": 0
|
|
343
|
+
},
|
|
330
344
|
{
|
|
331
345
|
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
332
346
|
"size": 1507,
|
|
@@ -355,7 +369,7 @@
|
|
|
355
369
|
"dependents": [
|
|
356
370
|
"/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts"
|
|
357
371
|
],
|
|
358
|
-
"percent": 1.
|
|
372
|
+
"percent": 1.5,
|
|
359
373
|
"reduction": 0
|
|
360
374
|
},
|
|
361
375
|
{
|
|
@@ -371,23 +385,9 @@
|
|
|
371
385
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
372
386
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
373
387
|
],
|
|
374
|
-
"percent": 1.
|
|
388
|
+
"percent": 1.33,
|
|
375
389
|
"reduction": 23.32
|
|
376
390
|
},
|
|
377
|
-
{
|
|
378
|
-
"id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
|
|
379
|
-
"size": 1118,
|
|
380
|
-
"origSize": 1151,
|
|
381
|
-
"renderedExports": [
|
|
382
|
-
"getPostBody"
|
|
383
|
-
],
|
|
384
|
-
"removedExports": [],
|
|
385
|
-
"dependents": [
|
|
386
|
-
"/src/adapters/node-http/content-type/json/index.ts"
|
|
387
|
-
],
|
|
388
|
-
"percent": 1.21,
|
|
389
|
-
"reduction": 2.87
|
|
390
|
-
},
|
|
391
391
|
{
|
|
392
392
|
"id": "/src/unstable-core-do-not-import/rpc/codes.ts",
|
|
393
393
|
"size": 1020,
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
],
|
|
399
399
|
"removedExports": [],
|
|
400
400
|
"dependents": [],
|
|
401
|
-
"percent": 1.
|
|
401
|
+
"percent": 1.1,
|
|
402
402
|
"reduction": 23.02
|
|
403
403
|
},
|
|
404
404
|
{
|
|
@@ -415,14 +415,14 @@
|
|
|
415
415
|
"dependents": [
|
|
416
416
|
"/src/unstable-core-do-not-import.ts",
|
|
417
417
|
"/src/unstable-core-do-not-import/rpc/codes.ts",
|
|
418
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
419
418
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
420
419
|
"/src/unstable-core-do-not-import/router.ts",
|
|
421
420
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
422
421
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
422
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
423
423
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
424
424
|
],
|
|
425
|
-
"percent": 1.
|
|
425
|
+
"percent": 1.08,
|
|
426
426
|
"reduction": 35.76
|
|
427
427
|
},
|
|
428
428
|
{
|
|
@@ -437,7 +437,7 @@
|
|
|
437
437
|
"/src/unstable-core-do-not-import.ts",
|
|
438
438
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
439
439
|
],
|
|
440
|
-
"percent": 1.
|
|
440
|
+
"percent": 1.07,
|
|
441
441
|
"reduction": 56.22
|
|
442
442
|
},
|
|
443
443
|
{
|
|
@@ -457,7 +457,7 @@
|
|
|
457
457
|
"/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts",
|
|
458
458
|
"/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts"
|
|
459
459
|
],
|
|
460
|
-
"percent": 0.
|
|
460
|
+
"percent": 0.78,
|
|
461
461
|
"reduction": 67.52
|
|
462
462
|
},
|
|
463
463
|
{
|
|
@@ -471,7 +471,7 @@
|
|
|
471
471
|
"dependents": [
|
|
472
472
|
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
473
473
|
],
|
|
474
|
-
"percent": 0.
|
|
474
|
+
"percent": 0.75,
|
|
475
475
|
"reduction": 71.21
|
|
476
476
|
},
|
|
477
477
|
{
|
|
@@ -498,21 +498,21 @@
|
|
|
498
498
|
"/src/unstable-core-do-not-import.ts",
|
|
499
499
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
|
|
500
500
|
],
|
|
501
|
-
"percent": 0.
|
|
501
|
+
"percent": 0.67,
|
|
502
502
|
"reduction": 43.49
|
|
503
503
|
},
|
|
504
504
|
{
|
|
505
505
|
"id": "/src/adapters/standalone.ts",
|
|
506
|
-
"size":
|
|
507
|
-
"origSize":
|
|
506
|
+
"size": 579,
|
|
507
|
+
"origSize": 1665,
|
|
508
508
|
"renderedExports": [
|
|
509
509
|
"createHTTPHandler",
|
|
510
510
|
"createHTTPServer"
|
|
511
511
|
],
|
|
512
512
|
"removedExports": [],
|
|
513
513
|
"dependents": [],
|
|
514
|
-
"percent": 0.
|
|
515
|
-
"reduction":
|
|
514
|
+
"percent": 0.62,
|
|
515
|
+
"reduction": 65.23
|
|
516
516
|
},
|
|
517
517
|
{
|
|
518
518
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
@@ -552,7 +552,7 @@
|
|
|
552
552
|
"dependents": [
|
|
553
553
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
554
554
|
],
|
|
555
|
-
"percent": 0.
|
|
555
|
+
"percent": 0.31,
|
|
556
556
|
"reduction": 35.11
|
|
557
557
|
},
|
|
558
558
|
{
|
|
@@ -590,8 +590,8 @@
|
|
|
590
590
|
],
|
|
591
591
|
"removedExports": [],
|
|
592
592
|
"dependents": [
|
|
593
|
-
"/src/adapters/node-http/content-type/
|
|
594
|
-
"/src/adapters/node-http/content-type/
|
|
593
|
+
"/src/adapters/node-http/content-type/form-data/index.ts",
|
|
594
|
+
"/src/adapters/node-http/content-type/json/index.ts"
|
|
595
595
|
],
|
|
596
596
|
"percent": 0.13,
|
|
597
597
|
"reduction": 86.68
|
|
@@ -638,9 +638,9 @@
|
|
|
638
638
|
"reduction": 100
|
|
639
639
|
},
|
|
640
640
|
{
|
|
641
|
-
"id": "/src/
|
|
641
|
+
"id": "/src/index.ts",
|
|
642
642
|
"size": 0,
|
|
643
|
-
"origSize":
|
|
643
|
+
"origSize": 32,
|
|
644
644
|
"renderedExports": [],
|
|
645
645
|
"removedExports": [],
|
|
646
646
|
"dependents": [],
|
|
@@ -648,9 +648,9 @@
|
|
|
648
648
|
"reduction": 100
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
|
-
"id": "/src/
|
|
651
|
+
"id": "/src/rpc.ts",
|
|
652
652
|
"size": 0,
|
|
653
|
-
"origSize":
|
|
653
|
+
"origSize": 36,
|
|
654
654
|
"renderedExports": [],
|
|
655
655
|
"removedExports": [],
|
|
656
656
|
"dependents": [],
|
|
@@ -700,26 +700,26 @@
|
|
|
700
700
|
"reduction": 100
|
|
701
701
|
},
|
|
702
702
|
{
|
|
703
|
-
"id": "/src/adapters/
|
|
703
|
+
"id": "/src/adapters/node-http/index.ts",
|
|
704
704
|
"size": 0,
|
|
705
|
-
"origSize":
|
|
705
|
+
"origSize": 67,
|
|
706
706
|
"renderedExports": [],
|
|
707
707
|
"removedExports": [],
|
|
708
|
-
"dependents": [
|
|
708
|
+
"dependents": [
|
|
709
|
+
"/src/adapters/express.ts",
|
|
710
|
+
"/src/adapters/standalone.ts",
|
|
711
|
+
"/src/adapters/next.ts"
|
|
712
|
+
],
|
|
709
713
|
"percent": 0,
|
|
710
714
|
"reduction": 100
|
|
711
715
|
},
|
|
712
716
|
{
|
|
713
|
-
"id": "/src/adapters/
|
|
717
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
714
718
|
"size": 0,
|
|
715
|
-
"origSize":
|
|
719
|
+
"origSize": 64,
|
|
716
720
|
"renderedExports": [],
|
|
717
721
|
"removedExports": [],
|
|
718
|
-
"dependents": [
|
|
719
|
-
"/src/adapters/express.ts",
|
|
720
|
-
"/src/adapters/next.ts",
|
|
721
|
-
"/src/adapters/standalone.ts"
|
|
722
|
-
],
|
|
722
|
+
"dependents": [],
|
|
723
723
|
"percent": 0,
|
|
724
724
|
"reduction": 100
|
|
725
725
|
}
|
|
@@ -88,7 +88,8 @@ async function resolveHTTPResponse(opts) {
|
|
|
88
88
|
return headResponse;
|
|
89
89
|
}
|
|
90
90
|
const contentTypeHandler = opts.contentTypeHandler ?? fallbackContentTypeHandler;
|
|
91
|
-
const
|
|
91
|
+
const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
|
|
92
|
+
const allowMethodOverride = opts.allowMethodOverride ?? false;
|
|
92
93
|
const type = HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? 'unknown';
|
|
93
94
|
let ctx = undefined;
|
|
94
95
|
let paths;
|
|
@@ -98,7 +99,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
98
99
|
if (opts.error) {
|
|
99
100
|
throw opts.error;
|
|
100
101
|
}
|
|
101
|
-
if (isBatchCall && !
|
|
102
|
+
if (isBatchCall && !allowBatching) {
|
|
102
103
|
throw new Error(`Batching is not enabled on the server`);
|
|
103
104
|
}
|
|
104
105
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
@@ -142,7 +143,8 @@ async function resolveHTTPResponse(opts) {
|
|
|
142
143
|
path,
|
|
143
144
|
getRawInput: async ()=>input,
|
|
144
145
|
ctx,
|
|
145
|
-
type
|
|
146
|
+
type,
|
|
147
|
+
allowMethodOverride
|
|
146
148
|
});
|
|
147
149
|
return {
|
|
148
150
|
result: {
|
|
@@ -86,7 +86,8 @@ async function resolveHTTPResponse(opts) {
|
|
|
86
86
|
return headResponse;
|
|
87
87
|
}
|
|
88
88
|
const contentTypeHandler = opts.contentTypeHandler ?? fallbackContentTypeHandler;
|
|
89
|
-
const
|
|
89
|
+
const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
|
|
90
|
+
const allowMethodOverride = opts.allowMethodOverride ?? false;
|
|
90
91
|
const type = HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? 'unknown';
|
|
91
92
|
let ctx = undefined;
|
|
92
93
|
let paths;
|
|
@@ -96,7 +97,7 @@ async function resolveHTTPResponse(opts) {
|
|
|
96
97
|
if (opts.error) {
|
|
97
98
|
throw opts.error;
|
|
98
99
|
}
|
|
99
|
-
if (isBatchCall && !
|
|
100
|
+
if (isBatchCall && !allowBatching) {
|
|
100
101
|
throw new Error(`Batching is not enabled on the server`);
|
|
101
102
|
}
|
|
102
103
|
/* istanbul ignore if -- @preserve */ if (type === 'subscription') {
|
|
@@ -140,7 +141,8 @@ async function resolveHTTPResponse(opts) {
|
|
|
140
141
|
path,
|
|
141
142
|
getRawInput: async ()=>input,
|
|
142
143
|
ctx,
|
|
143
|
-
type
|
|
144
|
+
type,
|
|
145
|
+
allowMethodOverride
|
|
144
146
|
});
|
|
145
147
|
return {
|
|
146
148
|
result: {
|
|
@@ -88,9 +88,26 @@ export type OnErrorFunction<TRouter extends AnyRouter, TRequest> = (opts: {
|
|
|
88
88
|
*/
|
|
89
89
|
export interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
|
|
90
90
|
onError?: OnErrorFunction<TRouter, TRequest>;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated use `allowBatching` instead
|
|
93
|
+
*/
|
|
91
94
|
batching?: {
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated use `allowBatching` instead, will be removed in v12
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
92
99
|
enabled: boolean;
|
|
93
100
|
};
|
|
94
101
|
router: TRouter;
|
|
102
|
+
/**
|
|
103
|
+
* Allow method override - will skip the method check
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
allowMethodOverride?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Allow request batching
|
|
109
|
+
* @default true
|
|
110
|
+
*/
|
|
111
|
+
allowBatching?: boolean;
|
|
95
112
|
}
|
|
96
113
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAE3E,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;IACzD,GAAG,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAClC;;QAEI;IACJ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,E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,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;CAC9C,KAAK,IAAI,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -62,6 +62,7 @@ export declare function createRouterFactory<TRoot extends AnyRootTypes>(config:
|
|
|
62
62
|
*/
|
|
63
63
|
export declare function callProcedure(opts: ProcedureCallOptions & {
|
|
64
64
|
procedures: RouterRecord;
|
|
65
|
+
allowMethodOverride?: boolean;
|
|
65
66
|
}): Promise<unknown>;
|
|
66
67
|
export declare function createCallerFactory<TRoot extends AnyRootTypes>(): <TRecord extends RouterRecord>(router: Router<TRoot, TRecord>) => RouterCaller<TRoot, TRecord>;
|
|
67
68
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAA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CAAC,QAAQ,CAAC,EAErE,OAAO,SAAS,YAAY,GAAG,EAAE,IAC/B,QAAQ,SAAS;IACnB,MAAM,IAAI,SAAS,SAAS;IAC5B,GAAG,MAAM,IAAI,SAAS,SAAS,EAAE;CAClC,GACG,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,GAC3D,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAEhC,wBAAgB,YAAY,CAAC,QAAQ,SAAS,SAAS,EAAE,EACvD,GAAG,UAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,GAC3B,YAAY,CAAC,QAAQ,CAAC,CAoDxB"}
|
|
@@ -102,7 +102,7 @@ function isProcedure(procedureOrRouter) {
|
|
|
102
102
|
*/ function callProcedure(opts) {
|
|
103
103
|
const { type , path } = opts;
|
|
104
104
|
const proc = opts.procedures[path];
|
|
105
|
-
if (!proc || !isProcedure(proc) || proc._def.type !== type) {
|
|
105
|
+
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
106
106
|
throw new TRPCError.TRPCError({
|
|
107
107
|
code: 'NOT_FOUND',
|
|
108
108
|
message: `No "${type}"-procedure on path "${path}"`
|
|
@@ -100,7 +100,7 @@ function isProcedure(procedureOrRouter) {
|
|
|
100
100
|
*/ function callProcedure(opts) {
|
|
101
101
|
const { type , path } = opts;
|
|
102
102
|
const proc = opts.procedures[path];
|
|
103
|
-
if (!proc || !isProcedure(proc) || proc._def.type !== type) {
|
|
103
|
+
if (!proc || !isProcedure(proc) || proc._def.type !== type && !opts.allowMethodOverride) {
|
|
104
104
|
throw new TRPCError({
|
|
105
105
|
code: 'NOT_FOUND',
|
|
106
106
|
message: `No "${type}"-procedure on path "${path}"`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-next-beta.
|
|
3
|
+
"version": "11.0.0-next-beta.302+95ed0a569",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"funding": [
|
|
158
158
|
"https://trpc.io/sponsor"
|
|
159
159
|
],
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "95ed0a569aa4ba8a0a5867f7df92f746f0d11f15"
|
|
161
161
|
}
|
|
@@ -9,6 +9,21 @@ export async function getPostBody(opts: {
|
|
|
9
9
|
}): Promise<BodyResult> {
|
|
10
10
|
const { req, maxBodySize = Infinity } = opts;
|
|
11
11
|
return new Promise((resolve) => {
|
|
12
|
+
if (
|
|
13
|
+
!req.headers['content-type']?.startsWith('application/json') &&
|
|
14
|
+
req.method !== 'GET' &&
|
|
15
|
+
req.method !== 'OPTIONS' &&
|
|
16
|
+
req.method !== 'HEAD'
|
|
17
|
+
) {
|
|
18
|
+
resolve({
|
|
19
|
+
ok: false,
|
|
20
|
+
error: new TRPCError({
|
|
21
|
+
code: 'BAD_REQUEST',
|
|
22
|
+
message: 'Invalid content-type header (expected application/json)',
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
12
27
|
if ('body' in req) {
|
|
13
28
|
resolve({
|
|
14
29
|
ok: true,
|
|
@@ -133,13 +133,10 @@ export async function nodeHTTPRequestHandler<
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
-
await resolveHTTPResponse({
|
|
137
|
-
|
|
138
|
-
responseMeta: opts.responseMeta,
|
|
139
|
-
path: opts.path,
|
|
140
|
-
createContext,
|
|
141
|
-
router: opts.router,
|
|
136
|
+
await resolveHTTPResponse<TRouter, HTTPRequest>({
|
|
137
|
+
...opts,
|
|
142
138
|
req,
|
|
139
|
+
createContext,
|
|
143
140
|
error: bodyResult.ok ? null : bodyResult.error,
|
|
144
141
|
preprocessedBody: bodyResult.ok ? bodyResult.preprocessed : false,
|
|
145
142
|
onError(o) {
|
|
@@ -233,7 +233,9 @@ export async function resolveHTTPResponse<
|
|
|
233
233
|
}
|
|
234
234
|
const contentTypeHandler =
|
|
235
235
|
opts.contentTypeHandler ?? fallbackContentTypeHandler;
|
|
236
|
-
const
|
|
236
|
+
const allowBatching = opts.allowBatching ?? opts.batching?.enabled ?? true;
|
|
237
|
+
const allowMethodOverride = opts.allowMethodOverride ?? false;
|
|
238
|
+
|
|
237
239
|
const type =
|
|
238
240
|
HTTP_METHOD_PROCEDURE_TYPE_MAP[req.method] ?? ('unknown' as const);
|
|
239
241
|
let ctx: inferRouterContext<TRouter> | undefined = undefined;
|
|
@@ -250,7 +252,7 @@ export async function resolveHTTPResponse<
|
|
|
250
252
|
if (opts.error) {
|
|
251
253
|
throw opts.error;
|
|
252
254
|
}
|
|
253
|
-
if (isBatchCall && !
|
|
255
|
+
if (isBatchCall && !allowBatching) {
|
|
254
256
|
throw new Error(`Batching is not enabled on the server`);
|
|
255
257
|
}
|
|
256
258
|
/* istanbul ignore if -- @preserve */
|
|
@@ -300,6 +302,7 @@ export async function resolveHTTPResponse<
|
|
|
300
302
|
getRawInput: async () => input,
|
|
301
303
|
ctx,
|
|
302
304
|
type,
|
|
305
|
+
allowMethodOverride,
|
|
303
306
|
});
|
|
304
307
|
return {
|
|
305
308
|
result: {
|
|
@@ -104,8 +104,25 @@ export type OnErrorFunction<TRouter extends AnyRouter, TRequest> = (opts: {
|
|
|
104
104
|
*/
|
|
105
105
|
export interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
|
|
106
106
|
onError?: OnErrorFunction<TRouter, TRequest>;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated use `allowBatching` instead
|
|
109
|
+
*/
|
|
107
110
|
batching?: {
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated use `allowBatching` instead, will be removed in v12
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
108
115
|
enabled: boolean;
|
|
109
116
|
};
|
|
110
117
|
router: TRouter;
|
|
118
|
+
/**
|
|
119
|
+
* Allow method override - will skip the method check
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
allowMethodOverride?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Allow request batching
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
allowBatching?: boolean;
|
|
111
128
|
}
|
|
@@ -221,11 +221,18 @@ function isProcedure(
|
|
|
221
221
|
* @internal
|
|
222
222
|
*/
|
|
223
223
|
export function callProcedure(
|
|
224
|
-
opts: ProcedureCallOptions & {
|
|
224
|
+
opts: ProcedureCallOptions & {
|
|
225
|
+
procedures: RouterRecord;
|
|
226
|
+
allowMethodOverride?: boolean;
|
|
227
|
+
},
|
|
225
228
|
) {
|
|
226
229
|
const { type, path } = opts;
|
|
227
230
|
const proc = opts.procedures[path];
|
|
228
|
-
if (
|
|
231
|
+
if (
|
|
232
|
+
!proc ||
|
|
233
|
+
!isProcedure(proc) ||
|
|
234
|
+
(proc._def.type !== type && !opts.allowMethodOverride)
|
|
235
|
+
) {
|
|
229
236
|
throw new TRPCError({
|
|
230
237
|
code: 'NOT_FOUND',
|
|
231
238
|
message: `No "${type}"-procedure on path "${path}"`,
|