@trpc/server 11.0.0-rc.346 → 11.0.0-rc.348
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/aws-lambda/content-type/json/index.js +2 -2
- package/dist/adapters/aws-lambda/content-type/json/index.mjs +2 -2
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts +8 -2
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +1 -1
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +13 -2
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +13 -2
- package/dist/adapters/fastify/content-type/json/index.js +2 -2
- package/dist/adapters/fastify/content-type/json/index.mjs +2 -2
- package/dist/adapters/fetch/content-type/json/index.d.ts.map +1 -1
- package/dist/adapters/fetch/content-type/json/index.js +2 -2
- package/dist/adapters/fetch/content-type/json/index.mjs +2 -2
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +2 -2
- package/dist/adapters/node-http/content-type/form-data/index.mjs +2 -2
- package/dist/adapters/node-http/content-type/json/index.js +2 -2
- package/dist/adapters/node-http/content-type/json/index.mjs +2 -2
- package/dist/adapters/node-http/content-type/octet/index.d.ts.map +1 -1
- package/dist/adapters/node-http/content-type/octet/index.js +2 -2
- package/dist/adapters/node-http/content-type/octet/index.mjs +2 -2
- package/dist/bundle-analysis.json +77 -77
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/aws-lambda/content-type/json/index.ts +2 -2
- package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +29 -5
- package/src/adapters/fastify/content-type/json/index.ts +2 -2
- package/src/adapters/fetch/content-type/json/index.ts +2 -4
- package/src/adapters/node-http/content-type/form-data/index.ts +2 -5
- package/src/adapters/node-http/content-type/json/index.ts +2 -2
- package/src/adapters/node-http/content-type/octet/index.ts +4 -6
- package/src/unstable-core-do-not-import/http/contentType.ts +1 -1
|
@@ -7,8 +7,8 @@ var utils = require('../../utils.js');
|
|
|
7
7
|
// @trpc/server
|
|
8
8
|
const getLambdaHTTPJSONContentTypeHandler = ()=>({
|
|
9
9
|
name: 'lambda-json',
|
|
10
|
-
isMatch (
|
|
11
|
-
return !!
|
|
10
|
+
isMatch: (headers)=>{
|
|
11
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
12
12
|
},
|
|
13
13
|
getInputs: async (opts, info)=>{
|
|
14
14
|
function getRawProcedureInputOrThrow() {
|
|
@@ -5,8 +5,8 @@ import { lambdaEventToHTTPBody } from '../../utils.mjs';
|
|
|
5
5
|
// @trpc/server
|
|
6
6
|
const getLambdaHTTPJSONContentTypeHandler = ()=>({
|
|
7
7
|
name: 'lambda-json',
|
|
8
|
-
isMatch (
|
|
9
|
-
return !!
|
|
8
|
+
isMatch: (headers)=>{
|
|
9
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
10
10
|
},
|
|
11
11
|
getInputs: async (opts, info)=>{
|
|
12
12
|
function getRawProcedureInputOrThrow() {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { TRPCError } from '../../@trpc/server';
|
|
2
|
-
import type { BaseContentTypeHandler } from '../../@trpc/server/http';
|
|
3
|
-
|
|
2
|
+
import type { BaseContentTypeHandler, HTTPHeaders } from '../../@trpc/server/http';
|
|
3
|
+
interface MinimalHandlerOpts {
|
|
4
|
+
req: {
|
|
5
|
+
headers: HTTPHeaders | Headers;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare function selectContentHandlerOrUnsupportedMediaType<THandlerOpts extends MinimalHandlerOpts, THandler extends BaseContentTypeHandler<THandlerOpts>>(handlers: THandler[], opts: THandlerOpts): readonly [undefined, TRPCError] | readonly [THandler];
|
|
9
|
+
export {};
|
|
4
10
|
//# sourceMappingURL=selectContentHandlerOrUnsupportedMediaType.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectContentHandlerOrUnsupportedMediaType.d.ts","sourceRoot":"","sources":["../../../src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"selectContentHandlerOrUnsupportedMediaType.d.ts","sourceRoot":"","sources":["../../../src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EACV,sBAAsB,EACtB,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAEjC,UAAU,kBAAkB;IAC1B,GAAG,EAAE;QAGH,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;KAChC,CAAC;CACH;AAED,wBAAgB,0CAA0C,CACxD,YAAY,SAAS,kBAAkB,EACvC,QAAQ,SAAS,sBAAsB,CAAC,YAAY,CAAC,EACrD,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,yDA2BzC"}
|
|
@@ -4,13 +4,24 @@ var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
|
|
|
4
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
5
5
|
|
|
6
6
|
function selectContentHandlerOrUnsupportedMediaType(handlers, opts) {
|
|
7
|
-
const
|
|
7
|
+
const headers = new Headers(opts.req.headers);
|
|
8
|
+
const contentType = headers.get('content-type');
|
|
9
|
+
if (contentType === null) {
|
|
10
|
+
return [
|
|
11
|
+
undefined,
|
|
12
|
+
new TRPCError.TRPCError({
|
|
13
|
+
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
14
|
+
message: 'No Content-Type header detected on the incoming request. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all'
|
|
15
|
+
})
|
|
16
|
+
];
|
|
17
|
+
}
|
|
18
|
+
const handler = handlers.find((handler)=>handler.isMatch(headers));
|
|
8
19
|
if (!handler) {
|
|
9
20
|
return [
|
|
10
21
|
undefined,
|
|
11
22
|
new TRPCError.TRPCError({
|
|
12
23
|
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
13
|
-
message:
|
|
24
|
+
message: `Invalid Content-Type header '${contentType}'. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all`
|
|
14
25
|
})
|
|
15
26
|
];
|
|
16
27
|
}
|
|
@@ -2,13 +2,24 @@ import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs
|
|
|
2
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
3
3
|
|
|
4
4
|
function selectContentHandlerOrUnsupportedMediaType(handlers, opts) {
|
|
5
|
-
const
|
|
5
|
+
const headers = new Headers(opts.req.headers);
|
|
6
|
+
const contentType = headers.get('content-type');
|
|
7
|
+
if (contentType === null) {
|
|
8
|
+
return [
|
|
9
|
+
undefined,
|
|
10
|
+
new TRPCError({
|
|
11
|
+
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
12
|
+
message: 'No Content-Type header detected on the incoming request. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all'
|
|
13
|
+
})
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
const handler = handlers.find((handler)=>handler.isMatch(headers));
|
|
6
17
|
if (!handler) {
|
|
7
18
|
return [
|
|
8
19
|
undefined,
|
|
9
20
|
new TRPCError({
|
|
10
21
|
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
11
|
-
message:
|
|
22
|
+
message: `Invalid Content-Type header '${contentType}'. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all`
|
|
12
23
|
})
|
|
13
24
|
];
|
|
14
25
|
}
|
|
@@ -6,8 +6,8 @@ require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
|
6
6
|
// @trpc/server
|
|
7
7
|
const getFastifyHTTPJSONContentTypeHandler = ()=>({
|
|
8
8
|
name: 'fastify-json',
|
|
9
|
-
isMatch (
|
|
10
|
-
return !!
|
|
9
|
+
isMatch: (headers)=>{
|
|
10
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
11
11
|
},
|
|
12
12
|
getInputs: async (opts, info)=>{
|
|
13
13
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -4,8 +4,8 @@ import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
|
4
4
|
// @trpc/server
|
|
5
5
|
const getFastifyHTTPJSONContentTypeHandler = ()=>({
|
|
6
6
|
name: 'fastify-json',
|
|
7
|
-
isMatch (
|
|
8
|
-
return !!
|
|
7
|
+
isMatch: (headers)=>{
|
|
8
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
9
9
|
},
|
|
10
10
|
getInputs: async (opts, info)=>{
|
|
11
11
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/fetch/content-type/json/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAEV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,SAAS,CACpE,SAAQ,sBAAsB,CAC5B,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,GAAG,CAAC;CACV,CACF;CAAG;AAEN,eAAO,MAAM,kCAAkC,EAAE,CAC/C,OAAO,SAAS,SAAS,OACpB,2BAA2B,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/fetch/content-type/json/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAEV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,SAAS,CACpE,SAAQ,sBAAsB,CAC5B,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,GAAG,CAAC;CACV,CACF;CAAG;AAEN,eAAO,MAAM,kCAAkC,EAAE,CAC/C,OAAO,SAAS,SAAS,OACpB,2BAA2B,CAAC,OAAO,CA2ExC,CAAC"}
|
|
@@ -6,8 +6,8 @@ require('../../../../unstable-core-do-not-import/rootConfig.js');
|
|
|
6
6
|
// @trpc/server
|
|
7
7
|
const getFetchHTTPJSONContentTypeHandler = ()=>({
|
|
8
8
|
name: 'fetch-json',
|
|
9
|
-
isMatch (
|
|
10
|
-
return !!
|
|
9
|
+
isMatch: (headers)=>{
|
|
10
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
11
11
|
},
|
|
12
12
|
getInputs: async (opts, info)=>{
|
|
13
13
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -4,8 +4,8 @@ import '../../../../unstable-core-do-not-import/rootConfig.mjs';
|
|
|
4
4
|
// @trpc/server
|
|
5
5
|
const getFetchHTTPJSONContentTypeHandler = ()=>({
|
|
6
6
|
name: 'fetch-json',
|
|
7
|
-
isMatch (
|
|
8
|
-
return !!
|
|
7
|
+
isMatch: (headers)=>{
|
|
8
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
9
9
|
},
|
|
10
10
|
getInputs: async (opts, info)=>{
|
|
11
11
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,6BAA6B,EAAE,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/form-data/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,6BAA6B,EAAE,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CA0B5D,CAAC"}
|
|
@@ -4,8 +4,8 @@ var node_stream = require('node:stream');
|
|
|
4
4
|
|
|
5
5
|
const getFormDataContentTypeHandler = ()=>({
|
|
6
6
|
name: 'node-http-formdata',
|
|
7
|
-
isMatch (
|
|
8
|
-
return
|
|
7
|
+
isMatch: (headers)=>{
|
|
8
|
+
return !!headers.get('content-type')?.startsWith('multipart/form-data');
|
|
9
9
|
},
|
|
10
10
|
async getInputs (opts, inputOpts) {
|
|
11
11
|
if (inputOpts.isBatchCall) {
|
|
@@ -2,8 +2,8 @@ import { Readable } from 'node:stream';
|
|
|
2
2
|
|
|
3
3
|
const getFormDataContentTypeHandler = ()=>({
|
|
4
4
|
name: 'node-http-formdata',
|
|
5
|
-
isMatch (
|
|
6
|
-
return
|
|
5
|
+
isMatch: (headers)=>{
|
|
6
|
+
return !!headers.get('content-type')?.startsWith('multipart/form-data');
|
|
7
7
|
},
|
|
8
8
|
async getInputs (opts, inputOpts) {
|
|
9
9
|
if (inputOpts.isBatchCall) {
|
|
@@ -7,8 +7,8 @@ var getPostBody = require('./getPostBody.js');
|
|
|
7
7
|
// @trpc/server
|
|
8
8
|
const getNodeHTTPJSONContentTypeHandler = ()=>({
|
|
9
9
|
name: 'node-http-json',
|
|
10
|
-
isMatch (
|
|
11
|
-
return !!
|
|
10
|
+
isMatch: (headers)=>{
|
|
11
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
12
12
|
},
|
|
13
13
|
getInputs: async (opts, info)=>{
|
|
14
14
|
const bodyResult = await getPostBody.getPostBody(opts);
|
|
@@ -5,8 +5,8 @@ import { getPostBody } from './getPostBody.mjs';
|
|
|
5
5
|
// @trpc/server
|
|
6
6
|
const getNodeHTTPJSONContentTypeHandler = ()=>({
|
|
7
7
|
name: 'node-http-json',
|
|
8
|
-
isMatch (
|
|
9
|
-
return !!
|
|
8
|
+
isMatch: (headers)=>{
|
|
9
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
10
10
|
},
|
|
11
11
|
getInputs: async (opts, info)=>{
|
|
12
12
|
const bodyResult = await getPostBody(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/octet/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,0BAA0B,EAAE,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/octet/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE3D,eAAO,MAAM,0BAA0B,EAAE,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,OAC7B,0BAA0B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAgB5D,CAAC"}
|
|
@@ -4,8 +4,8 @@ var node_stream = require('node:stream');
|
|
|
4
4
|
|
|
5
5
|
const getOctetContentTypeHandler = ()=>({
|
|
6
6
|
name: 'node-http-octet',
|
|
7
|
-
isMatch (
|
|
8
|
-
return
|
|
7
|
+
isMatch: (headers)=>{
|
|
8
|
+
return !!headers.get('content-type')?.startsWith('application/octet-stream');
|
|
9
9
|
},
|
|
10
10
|
async getInputs (opts, inputOpts) {
|
|
11
11
|
if (inputOpts.isBatchCall) {
|
|
@@ -2,8 +2,8 @@ import { Stream } from 'node:stream';
|
|
|
2
2
|
|
|
3
3
|
const getOctetContentTypeHandler = ()=>({
|
|
4
4
|
name: 'node-http-octet',
|
|
5
|
-
isMatch (
|
|
6
|
-
return
|
|
5
|
+
isMatch: (headers)=>{
|
|
6
|
+
return !!headers.get('content-type')?.startsWith('application/octet-stream');
|
|
7
7
|
},
|
|
8
8
|
async getInputs (opts, inputOpts) {
|
|
9
9
|
if (inputOpts.isBatchCall) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 34.
|
|
2
|
+
"bundleSize": 97925,
|
|
3
|
+
"bundleOrigSize": 148868,
|
|
4
|
+
"bundleReduction": 34.22,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/adapters/ws.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependents": [
|
|
16
16
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
17
17
|
],
|
|
18
|
-
"percent": 10.
|
|
18
|
+
"percent": 10.39,
|
|
19
19
|
"reduction": 0
|
|
20
20
|
},
|
|
21
21
|
{
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"removedExports": [],
|
|
29
29
|
"dependents": [],
|
|
30
|
-
"percent": 10
|
|
30
|
+
"percent": 10,
|
|
31
31
|
"reduction": 19.08
|
|
32
32
|
},
|
|
33
33
|
{
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"/src/unstable-core-do-not-import.ts",
|
|
44
44
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
45
45
|
],
|
|
46
|
-
"percent": 6.
|
|
46
|
+
"percent": 6.52,
|
|
47
47
|
"reduction": 59.29
|
|
48
48
|
},
|
|
49
49
|
{
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"removedExports": [],
|
|
60
60
|
"dependents": [
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
|
-
"/src/unstable-core-do-not-import/
|
|
63
|
-
"/src/unstable-core-do-not-import/
|
|
62
|
+
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
63
|
+
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
64
64
|
],
|
|
65
|
-
"percent": 6.
|
|
65
|
+
"percent": 6.11,
|
|
66
66
|
"reduction": 41.05
|
|
67
67
|
},
|
|
68
68
|
{
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"dependents": [
|
|
77
77
|
"/src/adapters/fetch/index.ts"
|
|
78
78
|
],
|
|
79
|
-
"percent": 3.
|
|
79
|
+
"percent": 3.89,
|
|
80
80
|
"reduction": 9.03
|
|
81
81
|
},
|
|
82
82
|
{
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"dependents": [
|
|
91
91
|
"/src/adapters/node-http/index.ts"
|
|
92
92
|
],
|
|
93
|
-
"percent": 3.
|
|
93
|
+
"percent": 3.68,
|
|
94
94
|
"reduction": 16.83
|
|
95
95
|
},
|
|
96
96
|
{
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"/src/adapters/aws-lambda/index.ts",
|
|
112
112
|
"/src/adapters/aws-lambda/content-type/json/index.ts"
|
|
113
113
|
],
|
|
114
|
-
"percent": 3.
|
|
114
|
+
"percent": 3.64,
|
|
115
115
|
"reduction": 30.57
|
|
116
116
|
},
|
|
117
117
|
{
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"/src/observable/index.ts",
|
|
129
129
|
"/src/observable/operators.ts"
|
|
130
130
|
],
|
|
131
|
-
"percent": 3.
|
|
131
|
+
"percent": 3.2,
|
|
132
132
|
"reduction": 0.67
|
|
133
133
|
},
|
|
134
134
|
{
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"dependents": [
|
|
143
143
|
"/src/adapters/next-app-dir.ts"
|
|
144
144
|
],
|
|
145
|
-
"percent": 3.
|
|
145
|
+
"percent": 3.11,
|
|
146
146
|
"reduction": 20.12
|
|
147
147
|
},
|
|
148
148
|
{
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
"/src/adapters/fastify/index.ts",
|
|
158
158
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
159
159
|
],
|
|
160
|
-
"percent": 2.
|
|
160
|
+
"percent": 2.87,
|
|
161
161
|
"reduction": 27.72
|
|
162
162
|
},
|
|
163
163
|
{
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
],
|
|
170
170
|
"removedExports": [],
|
|
171
171
|
"dependents": [],
|
|
172
|
-
"percent": 2.
|
|
172
|
+
"percent": 2.84,
|
|
173
173
|
"reduction": 32.14
|
|
174
174
|
},
|
|
175
175
|
{
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"dependents": [
|
|
186
186
|
"/src/observable/index.ts"
|
|
187
187
|
],
|
|
188
|
-
"percent": 2.
|
|
188
|
+
"percent": 2.81,
|
|
189
189
|
"reduction": 0
|
|
190
190
|
},
|
|
191
191
|
{
|
|
@@ -201,11 +201,11 @@
|
|
|
201
201
|
"removedExports": [],
|
|
202
202
|
"dependents": [
|
|
203
203
|
"/src/unstable-core-do-not-import.ts",
|
|
204
|
+
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
204
205
|
"/src/unstable-core-do-not-import/router.ts",
|
|
205
|
-
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
206
|
-
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
|
|
206
|
+
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
207
207
|
],
|
|
208
|
-
"percent": 2.
|
|
208
|
+
"percent": 2.8,
|
|
209
209
|
"reduction": 45.94
|
|
210
210
|
},
|
|
211
211
|
{
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"dependents": [
|
|
220
220
|
"/src/unstable-core-do-not-import.ts"
|
|
221
221
|
],
|
|
222
|
-
"percent": 2.
|
|
222
|
+
"percent": 2.71,
|
|
223
223
|
"reduction": 41.08
|
|
224
224
|
},
|
|
225
225
|
{
|
|
@@ -239,13 +239,13 @@
|
|
|
239
239
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
240
240
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.68,
|
|
243
243
|
"reduction": 55.5
|
|
244
244
|
},
|
|
245
245
|
{
|
|
246
246
|
"id": "/src/adapters/node-http/content-type/json/index.ts",
|
|
247
247
|
"size": 2464,
|
|
248
|
-
"origSize":
|
|
248
|
+
"origSize": 2500,
|
|
249
249
|
"renderedExports": [
|
|
250
250
|
"getNodeHTTPJSONContentTypeHandler"
|
|
251
251
|
],
|
|
@@ -253,13 +253,13 @@
|
|
|
253
253
|
"dependents": [
|
|
254
254
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
255
255
|
],
|
|
256
|
-
"percent": 2.
|
|
257
|
-
"reduction": 1.
|
|
256
|
+
"percent": 2.52,
|
|
257
|
+
"reduction": 1.44
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
260
|
"id": "/src/adapters/fastify/content-type/json/index.ts",
|
|
261
261
|
"size": 2355,
|
|
262
|
-
"origSize":
|
|
262
|
+
"origSize": 2753,
|
|
263
263
|
"renderedExports": [
|
|
264
264
|
"getFastifyHTTPJSONContentTypeHandler"
|
|
265
265
|
],
|
|
@@ -267,13 +267,13 @@
|
|
|
267
267
|
"dependents": [
|
|
268
268
|
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
269
269
|
],
|
|
270
|
-
"percent": 2.
|
|
271
|
-
"reduction": 14.
|
|
270
|
+
"percent": 2.4,
|
|
271
|
+
"reduction": 14.46
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
274
|
"id": "/src/adapters/fetch/content-type/json/index.ts",
|
|
275
|
-
"size":
|
|
276
|
-
"origSize":
|
|
275
|
+
"size": 2299,
|
|
276
|
+
"origSize": 2496,
|
|
277
277
|
"renderedExports": [
|
|
278
278
|
"getFetchHTTPJSONContentTypeHandler"
|
|
279
279
|
],
|
|
@@ -281,13 +281,13 @@
|
|
|
281
281
|
"dependents": [
|
|
282
282
|
"/src/adapters/fetch/fetchRequestHandler.ts"
|
|
283
283
|
],
|
|
284
|
-
"percent": 2.
|
|
285
|
-
"reduction":
|
|
284
|
+
"percent": 2.35,
|
|
285
|
+
"reduction": 7.89
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
288
|
"id": "/src/adapters/aws-lambda/content-type/json/index.ts",
|
|
289
|
-
"size":
|
|
290
|
-
"origSize":
|
|
289
|
+
"size": 2233,
|
|
290
|
+
"origSize": 2547,
|
|
291
291
|
"renderedExports": [
|
|
292
292
|
"getLambdaHTTPJSONContentTypeHandler"
|
|
293
293
|
],
|
|
@@ -295,8 +295,8 @@
|
|
|
295
295
|
"dependents": [
|
|
296
296
|
"/src/adapters/aws-lambda/index.ts"
|
|
297
297
|
],
|
|
298
|
-
"percent": 2.
|
|
299
|
-
"reduction": 12.
|
|
298
|
+
"percent": 2.28,
|
|
299
|
+
"reduction": 12.33
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
302
|
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
@@ -311,7 +311,7 @@
|
|
|
311
311
|
"/src/unstable-core-do-not-import.ts",
|
|
312
312
|
"/src/unstable-core-do-not-import/router.ts"
|
|
313
313
|
],
|
|
314
|
-
"percent": 2.
|
|
314
|
+
"percent": 2.04,
|
|
315
315
|
"reduction": 0
|
|
316
316
|
},
|
|
317
317
|
{
|
|
@@ -326,13 +326,13 @@
|
|
|
326
326
|
"removedExports": [],
|
|
327
327
|
"dependents": [
|
|
328
328
|
"/src/unstable-core-do-not-import.ts",
|
|
329
|
+
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
329
330
|
"/src/unstable-core-do-not-import/router.ts",
|
|
330
331
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
331
332
|
"/src/unstable-core-do-not-import/contentTypeParsers.ts",
|
|
332
|
-
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
333
333
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
334
334
|
],
|
|
335
|
-
"percent": 1.
|
|
335
|
+
"percent": 1.77,
|
|
336
336
|
"reduction": 19.47
|
|
337
337
|
},
|
|
338
338
|
{
|
|
@@ -344,7 +344,7 @@
|
|
|
344
344
|
],
|
|
345
345
|
"removedExports": [],
|
|
346
346
|
"dependents": [],
|
|
347
|
-
"percent": 1.
|
|
347
|
+
"percent": 1.61,
|
|
348
348
|
"reduction": 21.04
|
|
349
349
|
},
|
|
350
350
|
{
|
|
@@ -383,7 +383,7 @@
|
|
|
383
383
|
"dependents": [
|
|
384
384
|
"/src/adapters/fastify/index.ts"
|
|
385
385
|
],
|
|
386
|
-
"percent": 1.
|
|
386
|
+
"percent": 1.51,
|
|
387
387
|
"reduction": 34.61
|
|
388
388
|
},
|
|
389
389
|
{
|
|
@@ -396,10 +396,10 @@
|
|
|
396
396
|
],
|
|
397
397
|
"removedExports": [],
|
|
398
398
|
"dependents": [
|
|
399
|
-
"/src/unstable-core-do-not-import/
|
|
400
|
-
"/src/unstable-core-do-not-import/
|
|
399
|
+
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
400
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
401
401
|
],
|
|
402
|
-
"percent": 1.
|
|
402
|
+
"percent": 1.29,
|
|
403
403
|
"reduction": 22.76
|
|
404
404
|
},
|
|
405
405
|
{
|
|
@@ -418,8 +418,8 @@
|
|
|
418
418
|
},
|
|
419
419
|
{
|
|
420
420
|
"id": "/src/adapters/node-http/content-type/form-data/index.ts",
|
|
421
|
-
"size":
|
|
422
|
-
"origSize":
|
|
421
|
+
"size": 1043,
|
|
422
|
+
"origSize": 1254,
|
|
423
423
|
"renderedExports": [
|
|
424
424
|
"getFormDataContentTypeHandler"
|
|
425
425
|
],
|
|
@@ -427,8 +427,8 @@
|
|
|
427
427
|
"dependents": [
|
|
428
428
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
429
429
|
],
|
|
430
|
-
"percent": 1.
|
|
431
|
-
"reduction":
|
|
430
|
+
"percent": 1.07,
|
|
431
|
+
"reduction": 16.83
|
|
432
432
|
},
|
|
433
433
|
{
|
|
434
434
|
"id": "/src/unstable-core-do-not-import/parser.ts",
|
|
@@ -442,7 +442,7 @@
|
|
|
442
442
|
"/src/unstable-core-do-not-import.ts",
|
|
443
443
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
444
444
|
],
|
|
445
|
-
"percent": 1.
|
|
445
|
+
"percent": 1.01,
|
|
446
446
|
"reduction": 56.22
|
|
447
447
|
},
|
|
448
448
|
{
|
|
@@ -462,6 +462,23 @@
|
|
|
462
462
|
"percent": 1.01,
|
|
463
463
|
"reduction": 13.65
|
|
464
464
|
},
|
|
465
|
+
{
|
|
466
|
+
"id": "/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts",
|
|
467
|
+
"size": 974,
|
|
468
|
+
"origSize": 1402,
|
|
469
|
+
"renderedExports": [
|
|
470
|
+
"selectContentHandlerOrUnsupportedMediaType"
|
|
471
|
+
],
|
|
472
|
+
"removedExports": [],
|
|
473
|
+
"dependents": [
|
|
474
|
+
"/src/adapters/aws-lambda/index.ts",
|
|
475
|
+
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
476
|
+
"/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
477
|
+
"/src/adapters/fetch/fetchRequestHandler.ts"
|
|
478
|
+
],
|
|
479
|
+
"percent": 0.99,
|
|
480
|
+
"reduction": 30.53
|
|
481
|
+
},
|
|
465
482
|
{
|
|
466
483
|
"id": "/src/unstable-core-do-not-import/utils.ts",
|
|
467
484
|
"size": 880,
|
|
@@ -553,8 +570,8 @@
|
|
|
553
570
|
},
|
|
554
571
|
{
|
|
555
572
|
"id": "/src/adapters/node-http/content-type/octet/index.ts",
|
|
556
|
-
"size":
|
|
557
|
-
"origSize":
|
|
573
|
+
"size": 500,
|
|
574
|
+
"origSize": 841,
|
|
558
575
|
"renderedExports": [
|
|
559
576
|
"getOctetContentTypeHandler"
|
|
560
577
|
],
|
|
@@ -562,25 +579,8 @@
|
|
|
562
579
|
"dependents": [
|
|
563
580
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
564
581
|
],
|
|
565
|
-
"percent": 0.52,
|
|
566
|
-
"reduction": 41.18
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
"id": "/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts",
|
|
570
|
-
"size": 493,
|
|
571
|
-
"origSize": 682,
|
|
572
|
-
"renderedExports": [
|
|
573
|
-
"selectContentHandlerOrUnsupportedMediaType"
|
|
574
|
-
],
|
|
575
|
-
"removedExports": [],
|
|
576
|
-
"dependents": [
|
|
577
|
-
"/src/adapters/aws-lambda/index.ts",
|
|
578
|
-
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
579
|
-
"/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
580
|
-
"/src/adapters/fetch/fetchRequestHandler.ts"
|
|
581
|
-
],
|
|
582
582
|
"percent": 0.51,
|
|
583
|
-
"reduction":
|
|
583
|
+
"reduction": 40.55
|
|
584
584
|
},
|
|
585
585
|
{
|
|
586
586
|
"id": "/src/adapters/next-app-dir/rethrowNextErrors.ts",
|
|
@@ -695,9 +695,9 @@
|
|
|
695
695
|
"reduction": 93.8
|
|
696
696
|
},
|
|
697
697
|
{
|
|
698
|
-
"id": "/src/
|
|
698
|
+
"id": "/src/http.ts",
|
|
699
699
|
"size": 0,
|
|
700
|
-
"origSize":
|
|
700
|
+
"origSize": 37,
|
|
701
701
|
"renderedExports": [],
|
|
702
702
|
"removedExports": [],
|
|
703
703
|
"dependents": [],
|
|
@@ -705,9 +705,9 @@
|
|
|
705
705
|
"reduction": 100
|
|
706
706
|
},
|
|
707
707
|
{
|
|
708
|
-
"id": "/src/
|
|
708
|
+
"id": "/src/index.ts",
|
|
709
709
|
"size": 0,
|
|
710
|
-
"origSize":
|
|
710
|
+
"origSize": 32,
|
|
711
711
|
"renderedExports": [],
|
|
712
712
|
"removedExports": [],
|
|
713
713
|
"dependents": [],
|
|
@@ -725,9 +725,9 @@
|
|
|
725
725
|
"reduction": 100
|
|
726
726
|
},
|
|
727
727
|
{
|
|
728
|
-
"id": "/src/
|
|
728
|
+
"id": "/src/shared.ts",
|
|
729
729
|
"size": 0,
|
|
730
|
-
"origSize":
|
|
730
|
+
"origSize": 653,
|
|
731
731
|
"renderedExports": [],
|
|
732
732
|
"removedExports": [],
|
|
733
733
|
"dependents": [],
|
|
@@ -735,9 +735,9 @@
|
|
|
735
735
|
"reduction": 100
|
|
736
736
|
},
|
|
737
737
|
{
|
|
738
|
-
"id": "/src/
|
|
738
|
+
"id": "/src/unstable-core-do-not-import.ts",
|
|
739
739
|
"size": 0,
|
|
740
|
-
"origSize":
|
|
740
|
+
"origSize": 1498,
|
|
741
741
|
"renderedExports": [],
|
|
742
742
|
"removedExports": [],
|
|
743
743
|
"dependents": [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,MAAM,UAAU,GAClB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,sBAAsB,CAAC,QAAQ,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,MAAM,UAAU,GAClB;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;CACvB,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpC,MAAM,MAAM,sBAAsB,CAAC,QAAQ,IAAI;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IACnC,SAAS,EAAE,CACT,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,KACE,OAAO,CAAC,OAAO,CAAC,CAAC;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.348+9d8b631a7",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -159,5 +159,5 @@
|
|
|
159
159
|
"funding": [
|
|
160
160
|
"https://trpc.io/sponsor"
|
|
161
161
|
],
|
|
162
|
-
"gitHead": "
|
|
162
|
+
"gitHead": "9d8b631a7e78c94e19d9822abda61278664bceee"
|
|
163
163
|
}
|
|
@@ -29,8 +29,8 @@ export const getLambdaHTTPJSONContentTypeHandler: <
|
|
|
29
29
|
TEvent extends APIGatewayEvent,
|
|
30
30
|
>() => LambdaHTTPContentTypeHandler<TRouter, TEvent> = () => ({
|
|
31
31
|
name: 'lambda-json',
|
|
32
|
-
isMatch(
|
|
33
|
-
return !!
|
|
32
|
+
isMatch: (headers) => {
|
|
33
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
34
34
|
},
|
|
35
35
|
getInputs: async (opts, info) => {
|
|
36
36
|
function getRawProcedureInputOrThrow() {
|
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
import { TRPCError } from '../../@trpc/server';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
BaseContentTypeHandler,
|
|
4
|
+
HTTPHeaders,
|
|
5
|
+
} from '../../@trpc/server/http';
|
|
6
|
+
|
|
7
|
+
interface MinimalHandlerOpts {
|
|
8
|
+
req: {
|
|
9
|
+
// TODO: This could probably only take Headers and do the conversion higher up,
|
|
10
|
+
// but that's a bigger refactor for another day
|
|
11
|
+
headers: HTTPHeaders | Headers;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
3
14
|
|
|
4
15
|
export function selectContentHandlerOrUnsupportedMediaType<
|
|
5
|
-
THandlerOpts,
|
|
16
|
+
THandlerOpts extends MinimalHandlerOpts,
|
|
6
17
|
THandler extends BaseContentTypeHandler<THandlerOpts>,
|
|
7
18
|
>(handlers: THandler[], opts: THandlerOpts) {
|
|
8
|
-
const
|
|
9
|
-
|
|
19
|
+
const headers = new Headers(opts.req.headers as HeadersInit);
|
|
20
|
+
const contentType = headers.get('content-type');
|
|
21
|
+
|
|
22
|
+
if (contentType === null) {
|
|
10
23
|
return [
|
|
11
24
|
undefined,
|
|
12
25
|
new TRPCError({
|
|
13
26
|
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
14
27
|
message:
|
|
15
|
-
'
|
|
28
|
+
'No Content-Type header detected on the incoming request. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all',
|
|
29
|
+
}),
|
|
30
|
+
] as const;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const handler = handlers.find((handler) => handler.isMatch(headers));
|
|
34
|
+
if (!handler) {
|
|
35
|
+
return [
|
|
36
|
+
undefined,
|
|
37
|
+
new TRPCError({
|
|
38
|
+
code: 'UNSUPPORTED_MEDIA_TYPE',
|
|
39
|
+
message: `Invalid Content-Type header '${contentType}'. This request may not be supported by your tRPC Adapter, or possibly by tRPC at all`,
|
|
16
40
|
}),
|
|
17
41
|
] as const;
|
|
18
42
|
}
|
|
@@ -22,8 +22,8 @@ export const getFastifyHTTPJSONContentTypeHandler: <
|
|
|
22
22
|
TResponse extends FastifyReply,
|
|
23
23
|
>() => FastifyHTTPContentTypeHandler<TRouter, TRequest, TResponse> = () => ({
|
|
24
24
|
name: 'fastify-json',
|
|
25
|
-
isMatch(
|
|
26
|
-
return !!
|
|
25
|
+
isMatch: (headers) => {
|
|
26
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
27
27
|
},
|
|
28
28
|
getInputs: async (opts, info) => {
|
|
29
29
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -18,10 +18,8 @@ export const getFetchHTTPJSONContentTypeHandler: <
|
|
|
18
18
|
TRouter extends AnyRouter,
|
|
19
19
|
>() => FetchHTTPContentTypeHandler<TRouter> = () => ({
|
|
20
20
|
name: 'fetch-json',
|
|
21
|
-
isMatch(
|
|
22
|
-
return !!
|
|
23
|
-
.get('content-type')
|
|
24
|
-
?.startsWith('application/json');
|
|
21
|
+
isMatch: (headers) => {
|
|
22
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
25
23
|
},
|
|
26
24
|
getInputs: async (opts, info) => {
|
|
27
25
|
async function getRawProcedureInputOrThrow() {
|
|
@@ -10,11 +10,8 @@ export const getFormDataContentTypeHandler: <
|
|
|
10
10
|
TResponse extends NodeHTTPResponse,
|
|
11
11
|
>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse> = () => ({
|
|
12
12
|
name: 'node-http-formdata',
|
|
13
|
-
isMatch(
|
|
14
|
-
return (
|
|
15
|
-
opts.req.headers['content-type']?.startsWith('multipart/form-data') ??
|
|
16
|
-
false
|
|
17
|
-
);
|
|
13
|
+
isMatch: (headers) => {
|
|
14
|
+
return !!headers.get('content-type')?.startsWith('multipart/form-data');
|
|
18
15
|
},
|
|
19
16
|
async getInputs(opts, inputOpts) {
|
|
20
17
|
if (inputOpts.isBatchCall) {
|
|
@@ -14,8 +14,8 @@ export const getNodeHTTPJSONContentTypeHandler: <
|
|
|
14
14
|
TResponse extends NodeHTTPResponse,
|
|
15
15
|
>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse> = () => ({
|
|
16
16
|
name: 'node-http-json',
|
|
17
|
-
isMatch(
|
|
18
|
-
return !!
|
|
17
|
+
isMatch: (headers) => {
|
|
18
|
+
return !!headers.get('content-type')?.startsWith('application/json');
|
|
19
19
|
},
|
|
20
20
|
getInputs: async (opts, info) => {
|
|
21
21
|
const bodyResult = await getPostBody(opts);
|
|
@@ -10,12 +10,10 @@ export const getOctetContentTypeHandler: <
|
|
|
10
10
|
TResponse extends NodeHTTPResponse,
|
|
11
11
|
>() => NodeHTTPContentTypeHandler<TRouter, TRequest, TResponse> = () => ({
|
|
12
12
|
name: 'node-http-octet',
|
|
13
|
-
isMatch(
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
) ?? false
|
|
18
|
-
);
|
|
13
|
+
isMatch: (headers) => {
|
|
14
|
+
return !!headers
|
|
15
|
+
.get('content-type')
|
|
16
|
+
?.startsWith('application/octet-stream');
|
|
19
17
|
},
|
|
20
18
|
async getInputs(opts, inputOpts) {
|
|
21
19
|
if (inputOpts.isBatchCall) {
|