@trpc/server 11.0.0-rc.361 → 11.0.0-rc.363
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/@trpc/server/http.d.ts +7 -5
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/@trpc/server/index.d.ts +1 -2
- package/dist/@trpc/server/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/getPlanner.d.ts +13 -0
- package/dist/adapters/aws-lambda/getPlanner.d.ts.map +1 -0
- package/dist/adapters/aws-lambda/getPlanner.js +143 -0
- package/dist/adapters/aws-lambda/getPlanner.mjs +141 -0
- package/dist/adapters/aws-lambda/index.d.ts +12 -9
- package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.js +8 -77
- package/dist/adapters/aws-lambda/index.mjs +9 -72
- package/dist/adapters/express.js +1 -0
- package/dist/adapters/express.mjs +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +19 -2
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyRequestHandler.js +22 -64
- package/dist/adapters/fastify/fastifyRequestHandler.mjs +22 -64
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +1 -0
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -2
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +29 -86
- package/dist/adapters/fetch/fetchRequestHandler.mjs +29 -86
- package/dist/adapters/fetch/types.d.ts +2 -2
- package/dist/adapters/fetch/types.d.ts.map +1 -1
- package/dist/adapters/next.js +1 -1
- package/dist/adapters/next.mjs +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +18 -0
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -0
- package/dist/adapters/node-http/incomingMessageToRequest.js +71 -0
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +69 -0
- package/dist/adapters/node-http/index.d.ts +1 -0
- package/dist/adapters/node-http/index.d.ts.map +1 -1
- package/dist/adapters/node-http/index.js +2 -0
- package/dist/adapters/node-http/index.mjs +1 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +28 -71
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +28 -71
- package/dist/adapters/node-http/types.d.ts +7 -8
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +174 -271
- package/dist/http.js +4 -2
- package/dist/http.mjs +2 -1
- package/dist/index.js +2 -4
- package/dist/index.mjs +1 -2
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +8 -20
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/contentType.js +180 -0
- package/dist/unstable-core-do-not-import/http/contentType.mjs +178 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.js +14 -0
- package/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +12 -0
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts +15 -0
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.js → resolveResponse.js} +119 -134
- package/dist/unstable-core-do-not-import/http/{resolveHTTPResponse.mjs → resolveResponse.mjs} +119 -134
- package/dist/unstable-core-do-not-import/http/types.d.ts +25 -27
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +1 -3
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.js +0 -2
- package/dist/unstable-core-do-not-import/procedureBuilder.mjs +1 -2
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -9
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +3 -0
- package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/utils.js +2 -0
- package/dist/unstable-core-do-not-import/utils.mjs +2 -1
- package/dist/unstable-core-do-not-import.d.ts +9 -3
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +12 -8
- package/dist/unstable-core-do-not-import.mjs +7 -5
- package/package.json +3 -13
- package/src/@trpc/server/http.ts +7 -12
- package/src/@trpc/server/index.ts +0 -3
- package/src/adapters/aws-lambda/getPlanner.ts +191 -0
- package/src/adapters/aws-lambda/index.ts +43 -107
- package/src/adapters/express.ts +1 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +43 -90
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +4 -3
- package/src/adapters/fetch/fetchRequestHandler.ts +35 -111
- package/src/adapters/fetch/types.ts +4 -2
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/incomingMessageToRequest.ts +94 -0
- package/src/adapters/node-http/index.ts +1 -0
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +31 -97
- package/src/adapters/node-http/types.ts +27 -37
- package/src/adapters/standalone.ts +1 -1
- package/src/unstable-core-do-not-import/http/contentType.ts +214 -22
- package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +29 -0
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +386 -0
- package/src/unstable-core-do-not-import/http/types.ts +25 -30
- package/src/unstable-core-do-not-import/procedureBuilder.ts +2 -4
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -10
- package/src/unstable-core-do-not-import/utils.ts +4 -0
- package/src/unstable-core-do-not-import.ts +9 -3
- package/adapters/node-http/content-type/form-data/index.d.ts +0 -1
- package/adapters/node-http/content-type/form-data/index.js +0 -1
- package/adapters/node-http/content-type/json/index.d.ts +0 -1
- package/adapters/node-http/content-type/json/index.js +0 -1
- package/dist/adapters/aws-lambda/content-type/json/index.d.ts +0 -10
- package/dist/adapters/aws-lambda/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/content-type/json/index.js +0 -62
- package/dist/adapters/aws-lambda/content-type/json/index.mjs +0 -60
- package/dist/adapters/aws-lambda/utils.d.ts +0 -31
- package/dist/adapters/aws-lambda/utils.d.ts.map +0 -1
- package/dist/adapters/aws-lambda/utils.js +0 -111
- package/dist/adapters/aws-lambda/utils.mjs +0 -103
- package/dist/adapters/content-handlers/concurrentCache.d.ts +0 -7
- package/dist/adapters/content-handlers/concurrentCache.d.ts.map +0 -1
- package/dist/adapters/content-handlers/concurrentCache.js +0 -17
- package/dist/adapters/content-handlers/concurrentCache.mjs +0 -15
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts +0 -10
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.d.ts.map +0 -1
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.js +0 -33
- package/dist/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs +0 -31
- package/dist/adapters/fastify/content-type/json/index.d.ts +0 -8
- package/dist/adapters/fastify/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/fastify/content-type/json/index.js +0 -62
- package/dist/adapters/fastify/content-type/json/index.mjs +0 -60
- package/dist/adapters/fastify/types.d.ts +0 -11
- package/dist/adapters/fastify/types.d.ts.map +0 -1
- package/dist/adapters/fetch/content-type/json/index.d.ts +0 -9
- package/dist/adapters/fetch/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/fetch/content-type/json/index.js +0 -55
- package/dist/adapters/fetch/content-type/json/index.mjs +0 -53
- package/dist/adapters/node-http/content-type/form-data/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/form-data/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/form-data/index.js +0 -32
- package/dist/adapters/node-http/content-type/form-data/index.mjs +0 -30
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +0 -7
- package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/getPostBody.js +0 -45
- package/dist/adapters/node-http/content-type/json/getPostBody.mjs +0 -43
- package/dist/adapters/node-http/content-type/json/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/json/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/json/index.js +0 -68
- package/dist/adapters/node-http/content-type/json/index.mjs +0 -66
- package/dist/adapters/node-http/content-type/octet/index.d.ts +0 -5
- package/dist/adapters/node-http/content-type/octet/index.d.ts.map +0 -1
- package/dist/adapters/node-http/content-type/octet/index.js +0 -19
- package/dist/adapters/node-http/content-type/octet/index.mjs +0 -17
- package/dist/adapters/node-http/content-type/types.d.ts +0 -8
- package/dist/adapters/node-http/content-type/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts +0 -16
- package/dist/unstable-core-do-not-import/contentTypeParsers.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/contentTypeParsers.js +0 -23
- package/dist/unstable-core-do-not-import/contentTypeParsers.mjs +0 -21
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -11
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/src/adapters/aws-lambda/content-type/json/index.ts +0 -108
- package/src/adapters/aws-lambda/utils.ts +0 -170
- package/src/adapters/content-handlers/concurrentCache.ts +0 -16
- package/src/adapters/content-handlers/selectContentHandlerOrUnsupportedMediaType.ts +0 -45
- package/src/adapters/fastify/content-type/json/index.ts +0 -106
- package/src/adapters/fastify/types.ts +0 -22
- package/src/adapters/fetch/content-type/json/index.ts +0 -90
- package/src/adapters/node-http/content-type/form-data/index.ts +0 -37
- package/src/adapters/node-http/content-type/json/getPostBody.ts +0 -49
- package/src/adapters/node-http/content-type/json/index.ts +0 -100
- package/src/adapters/node-http/content-type/octet/index.ts +0 -27
- package/src/adapters/node-http/content-type/types.ts +0 -19
- package/src/unstable-core-do-not-import/contentTypeParsers.ts +0 -37
- package/src/unstable-core-do-not-import/http/index.ts +0 -28
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -461
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
5
|
-
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
3
|
+
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
6
4
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
7
|
-
var
|
|
8
|
-
var index = require('./content-type/json/index.js');
|
|
5
|
+
var incomingMessageToRequest = require('../node-http/incomingMessageToRequest.js');
|
|
9
6
|
|
|
7
|
+
/**
|
|
8
|
+
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
13
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
14
|
+
* ```
|
|
15
|
+
*/ // @trpc/server/http
|
|
10
16
|
async function fastifyRequestHandler(opts) {
|
|
11
17
|
const createContext = async (innerOpts)=>{
|
|
12
18
|
return await opts.createContext?.({
|
|
@@ -14,75 +20,27 @@ async function fastifyRequestHandler(opts) {
|
|
|
14
20
|
...innerOpts
|
|
15
21
|
});
|
|
16
22
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
let stream;
|
|
27
|
-
let formatter;
|
|
28
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
29
|
-
if (!opts.res.statusCode || opts.res.statusCode === 200) {
|
|
30
|
-
opts.res.statusCode = head.status;
|
|
31
|
-
}
|
|
32
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
33
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
void opts.res.header(key, value);
|
|
37
|
-
}
|
|
38
|
-
if (isStreaming) {
|
|
39
|
-
void opts.res.header('Transfer-Encoding', 'chunked');
|
|
40
|
-
void opts.res.header('Vary', opts.res.hasHeader('Vary') ? 'trpc-batch-mode, ' + opts.res.getHeader('Vary') : 'trpc-batch-mode');
|
|
41
|
-
stream = new node_stream.Readable();
|
|
42
|
-
stream._read = ()=>{}; // eslint-disable-line @typescript-eslint/no-empty-function -- https://github.com/fastify/fastify/issues/805#issuecomment-369172154
|
|
43
|
-
resolve(opts.res.send(stream));
|
|
44
|
-
isStream = true;
|
|
45
|
-
formatter = batchStreamFormatter.getBatchStreamFormatter();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const unstable_onChunk = ([index, string])=>{
|
|
49
|
-
if (index === -1) {
|
|
50
|
-
// full response, no streaming
|
|
51
|
-
resolve(opts.res.send(string));
|
|
52
|
-
} else {
|
|
53
|
-
stream.push(formatter(index, string));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType.selectContentHandlerOrUnsupportedMediaType([
|
|
57
|
-
index.getFastifyHTTPJSONContentTypeHandler()
|
|
58
|
-
], opts);
|
|
59
|
-
resolveHTTPResponse.resolveHTTPResponse({
|
|
23
|
+
const incomingMessage = opts.req.raw;
|
|
24
|
+
// monkey-path body to the IncomingMessage
|
|
25
|
+
if ('body' in opts.req) {
|
|
26
|
+
incomingMessage.body = opts.req.body;
|
|
27
|
+
}
|
|
28
|
+
const req = incomingMessageToRequest.incomingMessageToRequest(incomingMessage, {
|
|
29
|
+
maxBodySize: null
|
|
30
|
+
});
|
|
31
|
+
const res = await resolveResponse.resolveResponse({
|
|
60
32
|
...opts,
|
|
61
33
|
req,
|
|
62
|
-
error:
|
|
63
|
-
async getInput (info) {
|
|
64
|
-
return await contentTypeHandler?.getInputs(opts, info);
|
|
65
|
-
},
|
|
34
|
+
error: null,
|
|
66
35
|
createContext,
|
|
67
36
|
onError (o) {
|
|
68
37
|
opts?.onError?.({
|
|
69
38
|
...o,
|
|
70
39
|
req: opts.req
|
|
71
40
|
});
|
|
72
|
-
},
|
|
73
|
-
unstable_onHead,
|
|
74
|
-
unstable_onChunk
|
|
75
|
-
}).then(()=>{
|
|
76
|
-
if (isStream) {
|
|
77
|
-
stream.push(formatter.end());
|
|
78
|
-
stream.push(null); // https://github.com/fastify/fastify/issues/805#issuecomment-369172154
|
|
79
|
-
}
|
|
80
|
-
}).catch(()=>{
|
|
81
|
-
if (isStream) {
|
|
82
|
-
stream.push(null);
|
|
83
41
|
}
|
|
84
42
|
});
|
|
85
|
-
|
|
43
|
+
await opts.res.send(res);
|
|
86
44
|
}
|
|
87
45
|
|
|
88
46
|
exports.fastifyRequestHandler = fastifyRequestHandler;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
3
|
-
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
1
|
+
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
4
2
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import { getFastifyHTTPJSONContentTypeHandler } from './content-type/json/index.mjs';
|
|
3
|
+
import { incomingMessageToRequest } from '../node-http/incomingMessageToRequest.mjs';
|
|
7
4
|
|
|
5
|
+
/**
|
|
6
|
+
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
11
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
12
|
+
* ```
|
|
13
|
+
*/ // @trpc/server/http
|
|
8
14
|
async function fastifyRequestHandler(opts) {
|
|
9
15
|
const createContext = async (innerOpts)=>{
|
|
10
16
|
return await opts.createContext?.({
|
|
@@ -12,75 +18,27 @@ async function fastifyRequestHandler(opts) {
|
|
|
12
18
|
...innerOpts
|
|
13
19
|
});
|
|
14
20
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let stream;
|
|
25
|
-
let formatter;
|
|
26
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
27
|
-
if (!opts.res.statusCode || opts.res.statusCode === 200) {
|
|
28
|
-
opts.res.statusCode = head.status;
|
|
29
|
-
}
|
|
30
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
31
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
void opts.res.header(key, value);
|
|
35
|
-
}
|
|
36
|
-
if (isStreaming) {
|
|
37
|
-
void opts.res.header('Transfer-Encoding', 'chunked');
|
|
38
|
-
void opts.res.header('Vary', opts.res.hasHeader('Vary') ? 'trpc-batch-mode, ' + opts.res.getHeader('Vary') : 'trpc-batch-mode');
|
|
39
|
-
stream = new Readable();
|
|
40
|
-
stream._read = ()=>{}; // eslint-disable-line @typescript-eslint/no-empty-function -- https://github.com/fastify/fastify/issues/805#issuecomment-369172154
|
|
41
|
-
resolve(opts.res.send(stream));
|
|
42
|
-
isStream = true;
|
|
43
|
-
formatter = getBatchStreamFormatter();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
const unstable_onChunk = ([index, string])=>{
|
|
47
|
-
if (index === -1) {
|
|
48
|
-
// full response, no streaming
|
|
49
|
-
resolve(opts.res.send(string));
|
|
50
|
-
} else {
|
|
51
|
-
stream.push(formatter(index, string));
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType([
|
|
55
|
-
getFastifyHTTPJSONContentTypeHandler()
|
|
56
|
-
], opts);
|
|
57
|
-
resolveHTTPResponse({
|
|
21
|
+
const incomingMessage = opts.req.raw;
|
|
22
|
+
// monkey-path body to the IncomingMessage
|
|
23
|
+
if ('body' in opts.req) {
|
|
24
|
+
incomingMessage.body = opts.req.body;
|
|
25
|
+
}
|
|
26
|
+
const req = incomingMessageToRequest(incomingMessage, {
|
|
27
|
+
maxBodySize: null
|
|
28
|
+
});
|
|
29
|
+
const res = await resolveResponse({
|
|
58
30
|
...opts,
|
|
59
31
|
req,
|
|
60
|
-
error:
|
|
61
|
-
async getInput (info) {
|
|
62
|
-
return await contentTypeHandler?.getInputs(opts, info);
|
|
63
|
-
},
|
|
32
|
+
error: null,
|
|
64
33
|
createContext,
|
|
65
34
|
onError (o) {
|
|
66
35
|
opts?.onError?.({
|
|
67
36
|
...o,
|
|
68
37
|
req: opts.req
|
|
69
38
|
});
|
|
70
|
-
},
|
|
71
|
-
unstable_onHead,
|
|
72
|
-
unstable_onChunk
|
|
73
|
-
}).then(()=>{
|
|
74
|
-
if (isStream) {
|
|
75
|
-
stream.push(formatter.end());
|
|
76
|
-
stream.push(null); // https://github.com/fastify/fastify/issues/805#issuecomment-369172154
|
|
77
|
-
}
|
|
78
|
-
}).catch(()=>{
|
|
79
|
-
if (isStream) {
|
|
80
|
-
stream.push(null);
|
|
81
39
|
}
|
|
82
40
|
});
|
|
83
|
-
|
|
41
|
+
await opts.res.send(res);
|
|
84
42
|
}
|
|
85
43
|
|
|
86
44
|
export { fastifyRequestHandler };
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
11
11
|
import type { AnyRouter } from '../../@trpc/server';
|
|
12
12
|
import type { NodeHTTPCreateContextFnOptions } from '../node-http';
|
|
13
|
-
import type { FastifyHandlerOptions } from './
|
|
13
|
+
import type { FastifyHandlerOptions } from './fastifyRequestHandler';
|
|
14
14
|
export interface FastifyTRPCPluginOptions<TRouter extends AnyRouter> {
|
|
15
15
|
prefix?: string;
|
|
16
16
|
useWSS?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAmC5B"}
|
|
@@ -12,6 +12,7 @@ var fastifyRequestHandler = require('./fastifyRequestHandler.js');
|
|
|
12
12
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
13
13
|
* ```
|
|
14
14
|
*/ /// <reference types="@fastify/websocket" />
|
|
15
|
+
// @trpc/server/ws
|
|
15
16
|
function fastifyTRPCPlugin(fastify, opts, done) {
|
|
16
17
|
fastify.removeContentTypeParser('application/json');
|
|
17
18
|
fastify.addContentTypeParser('application/json', {
|
|
@@ -10,6 +10,7 @@ import { fastifyRequestHandler } from './fastifyRequestHandler.mjs';
|
|
|
10
10
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
11
11
|
* ```
|
|
12
12
|
*/ /// <reference types="@fastify/websocket" />
|
|
13
|
+
// @trpc/server/ws
|
|
13
14
|
function fastifyTRPCPlugin(fastify, opts, done) {
|
|
14
15
|
fastify.removeContentTypeParser('application/json');
|
|
15
16
|
fastify.addContentTypeParser('application/json', {
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
10
|
import type { AnyRouter } from '../../@trpc/server';
|
|
11
|
-
import type {
|
|
12
|
-
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts:
|
|
11
|
+
import type { FetchHandlerRequestOptions } from './types';
|
|
12
|
+
export declare function fetchRequestHandler<TRouter extends AnyRouter>(opts: FetchHandlerRequestOptions<TRouter>): Promise<Response>;
|
|
13
13
|
//# sourceMappingURL=fetchRequestHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAS1D,wBAAsB,mBAAmB,CAAC,OAAO,SAAS,SAAS,EACjE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACxC,OAAO,CAAC,QAAQ,CAAC,CAsDnB"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
3
|
+
var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
|
|
5
4
|
var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
|
|
6
5
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
7
|
-
var selectContentHandlerOrUnsupportedMediaType = require('../content-handlers/selectContentHandlerOrUnsupportedMediaType.js');
|
|
8
|
-
var index = require('./content-type/json/index.js');
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
8
|
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
@@ -34,99 +31,45 @@ async function fetchRequestHandler(opts) {
|
|
|
34
31
|
const pathname = trimSlashes(url.pathname);
|
|
35
32
|
const endpoint = trimSlashes(opts.endpoint);
|
|
36
33
|
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
37
|
-
|
|
38
|
-
query: url.searchParams,
|
|
39
|
-
method: opts.req.method,
|
|
40
|
-
headers: Object.fromEntries(opts.req.headers)
|
|
41
|
-
};
|
|
42
|
-
let resolve;
|
|
43
|
-
const promise = new Promise((r)=>resolve = r);
|
|
44
|
-
let status = 200;
|
|
45
|
-
let isStream = false;
|
|
46
|
-
let controller;
|
|
47
|
-
let encoder;
|
|
48
|
-
let formatter;
|
|
49
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
50
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
51
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
if (typeof value === 'string') {
|
|
55
|
-
resHeaders.set(key, value);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
for (const v of value){
|
|
59
|
-
resHeaders.append(key, v);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
status = head.status;
|
|
63
|
-
if (isStreaming) {
|
|
64
|
-
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
65
|
-
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
66
|
-
const stream = new ReadableStream({
|
|
67
|
-
start (c) {
|
|
68
|
-
controller = c;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
const response = new Response(stream, {
|
|
72
|
-
status,
|
|
73
|
-
headers: resHeaders
|
|
74
|
-
});
|
|
75
|
-
resolve(response);
|
|
76
|
-
encoder = new TextEncoder();
|
|
77
|
-
formatter = batchStreamFormatter.getBatchStreamFormatter();
|
|
78
|
-
isStream = true;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const unstable_onChunk = ([index, string])=>{
|
|
82
|
-
if (index === -1) {
|
|
83
|
-
// full response, no streaming
|
|
84
|
-
const response = new Response(string || null, {
|
|
85
|
-
status,
|
|
86
|
-
headers: resHeaders
|
|
87
|
-
});
|
|
88
|
-
resolve(response);
|
|
89
|
-
} else {
|
|
90
|
-
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType.selectContentHandlerOrUnsupportedMediaType([
|
|
94
|
-
index.getFetchHTTPJSONContentTypeHandler()
|
|
95
|
-
], {
|
|
96
|
-
...opts,
|
|
97
|
-
url
|
|
98
|
-
});
|
|
99
|
-
resolveHTTPResponse.resolveHTTPResponse({
|
|
34
|
+
return await resolveResponse.resolveResponse({
|
|
100
35
|
...opts,
|
|
101
|
-
req,
|
|
36
|
+
req: opts.req,
|
|
102
37
|
createContext,
|
|
103
38
|
path,
|
|
104
|
-
error:
|
|
105
|
-
async getInput (info) {
|
|
106
|
-
return await contentTypeHandler?.getInputs({
|
|
107
|
-
...opts,
|
|
108
|
-
url
|
|
109
|
-
}, info);
|
|
110
|
-
},
|
|
39
|
+
error: null,
|
|
111
40
|
onError (o) {
|
|
112
41
|
opts?.onError?.({
|
|
113
42
|
...o,
|
|
114
43
|
req: opts.req
|
|
115
44
|
});
|
|
116
45
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
46
|
+
responseMeta (data) {
|
|
47
|
+
const meta = opts.responseMeta?.(data);
|
|
48
|
+
if (meta?.headers) {
|
|
49
|
+
if (meta.headers instanceof Headers) {
|
|
50
|
+
for (const [key, value] of meta.headers.entries()){
|
|
51
|
+
resHeaders.append(key, value);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated, delete in v12
|
|
56
|
+
*/ for (const [key1, value1] of Object.entries(meta.headers)){
|
|
57
|
+
if (Array.isArray(value1)) {
|
|
58
|
+
for (const v of value1){
|
|
59
|
+
resHeaders.append(key1, v);
|
|
60
|
+
}
|
|
61
|
+
} else if (typeof value1 === 'string') {
|
|
62
|
+
resHeaders.set(key1, value1);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
headers: resHeaders,
|
|
69
|
+
status: meta?.status
|
|
70
|
+
};
|
|
127
71
|
}
|
|
128
72
|
});
|
|
129
|
-
return promise;
|
|
130
73
|
}
|
|
131
74
|
|
|
132
75
|
exports.fetchRequestHandler = fetchRequestHandler;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
1
|
+
import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
|
|
3
2
|
import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
|
|
4
3
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
5
|
-
import { selectContentHandlerOrUnsupportedMediaType } from '../content-handlers/selectContentHandlerOrUnsupportedMediaType.mjs';
|
|
6
|
-
import { getFetchHTTPJSONContentTypeHandler } from './content-type/json/index.mjs';
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`
|
|
@@ -32,99 +29,45 @@ async function fetchRequestHandler(opts) {
|
|
|
32
29
|
const pathname = trimSlashes(url.pathname);
|
|
33
30
|
const endpoint = trimSlashes(opts.endpoint);
|
|
34
31
|
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
35
|
-
|
|
36
|
-
query: url.searchParams,
|
|
37
|
-
method: opts.req.method,
|
|
38
|
-
headers: Object.fromEntries(opts.req.headers)
|
|
39
|
-
};
|
|
40
|
-
let resolve;
|
|
41
|
-
const promise = new Promise((r)=>resolve = r);
|
|
42
|
-
let status = 200;
|
|
43
|
-
let isStream = false;
|
|
44
|
-
let controller;
|
|
45
|
-
let encoder;
|
|
46
|
-
let formatter;
|
|
47
|
-
const unstable_onHead = (head, isStreaming)=>{
|
|
48
|
-
for (const [key, value] of Object.entries(head.headers ?? {})){
|
|
49
|
-
/* istanbul ignore if -- @preserve */ if (typeof value === 'undefined') {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (typeof value === 'string') {
|
|
53
|
-
resHeaders.set(key, value);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
for (const v of value){
|
|
57
|
-
resHeaders.append(key, v);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
status = head.status;
|
|
61
|
-
if (isStreaming) {
|
|
62
|
-
resHeaders.set('Transfer-Encoding', 'chunked');
|
|
63
|
-
resHeaders.append('Vary', 'trpc-batch-mode');
|
|
64
|
-
const stream = new ReadableStream({
|
|
65
|
-
start (c) {
|
|
66
|
-
controller = c;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
const response = new Response(stream, {
|
|
70
|
-
status,
|
|
71
|
-
headers: resHeaders
|
|
72
|
-
});
|
|
73
|
-
resolve(response);
|
|
74
|
-
encoder = new TextEncoder();
|
|
75
|
-
formatter = getBatchStreamFormatter();
|
|
76
|
-
isStream = true;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const unstable_onChunk = ([index, string])=>{
|
|
80
|
-
if (index === -1) {
|
|
81
|
-
// full response, no streaming
|
|
82
|
-
const response = new Response(string || null, {
|
|
83
|
-
status,
|
|
84
|
-
headers: resHeaders
|
|
85
|
-
});
|
|
86
|
-
resolve(response);
|
|
87
|
-
} else {
|
|
88
|
-
controller.enqueue(encoder.encode(formatter(index, string)));
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const [contentTypeHandler, unsupportedMediaTypeError] = selectContentHandlerOrUnsupportedMediaType([
|
|
92
|
-
getFetchHTTPJSONContentTypeHandler()
|
|
93
|
-
], {
|
|
94
|
-
...opts,
|
|
95
|
-
url
|
|
96
|
-
});
|
|
97
|
-
resolveHTTPResponse({
|
|
32
|
+
return await resolveResponse({
|
|
98
33
|
...opts,
|
|
99
|
-
req,
|
|
34
|
+
req: opts.req,
|
|
100
35
|
createContext,
|
|
101
36
|
path,
|
|
102
|
-
error:
|
|
103
|
-
async getInput (info) {
|
|
104
|
-
return await contentTypeHandler?.getInputs({
|
|
105
|
-
...opts,
|
|
106
|
-
url
|
|
107
|
-
}, info);
|
|
108
|
-
},
|
|
37
|
+
error: null,
|
|
109
38
|
onError (o) {
|
|
110
39
|
opts?.onError?.({
|
|
111
40
|
...o,
|
|
112
41
|
req: opts.req
|
|
113
42
|
});
|
|
114
43
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
44
|
+
responseMeta (data) {
|
|
45
|
+
const meta = opts.responseMeta?.(data);
|
|
46
|
+
if (meta?.headers) {
|
|
47
|
+
if (meta.headers instanceof Headers) {
|
|
48
|
+
for (const [key, value] of meta.headers.entries()){
|
|
49
|
+
resHeaders.append(key, value);
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated, delete in v12
|
|
54
|
+
*/ for (const [key1, value1] of Object.entries(meta.headers)){
|
|
55
|
+
if (Array.isArray(value1)) {
|
|
56
|
+
for (const v of value1){
|
|
57
|
+
resHeaders.append(key1, v);
|
|
58
|
+
}
|
|
59
|
+
} else if (typeof value1 === 'string') {
|
|
60
|
+
resHeaders.set(key1, value1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
headers: resHeaders,
|
|
67
|
+
status: meta?.status
|
|
68
|
+
};
|
|
125
69
|
}
|
|
126
70
|
});
|
|
127
|
-
return promise;
|
|
128
71
|
}
|
|
129
72
|
|
|
130
73
|
export { fetchRequestHandler };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
|
-
import type { AnyRouter, CreateContextCallback, inferRouterContext
|
|
10
|
+
import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../../@trpc/server';
|
|
11
11
|
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
12
12
|
export type FetchCreateContextFnOptions = {
|
|
13
13
|
req: Request;
|
|
@@ -20,7 +20,7 @@ export type FetchHandlerOptions<TRouter extends AnyRouter> = FetchCreateContextO
|
|
|
20
20
|
req: Request;
|
|
21
21
|
endpoint: string;
|
|
22
22
|
};
|
|
23
|
-
export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHandlerOptions<TRouter, Request> &
|
|
23
|
+
export type FetchHandlerRequestOptions<TRouter extends AnyRouter> = HTTPBaseHandlerOptions<TRouter, Request> & CreateContextCallback<inferRouterContext<TRouter>, FetchCreateContextFn<TRouter>> & {
|
|
24
24
|
req: Request;
|
|
25
25
|
endpoint: string;
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC5D,IAAI,EAAE,2BAA2B,KAC9B,kBAAkB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,oBAAoB,CAAC,OAAO,CAAC,CAC9B,CAAC;AAEJ,MAAM,MAAM,mBAAmB,CAAC,OAAO,SAAS,SAAS,IACvD,wBAAwB,CAAC,OAAO,CAAC,GAC/B,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG;IACzC,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEN,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,GACtC,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,oBAAoB,CAAC,OAAO,CAAC,CAC9B,GAAG;IACF,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
package/dist/adapters/next.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
|
|
4
3
|
var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
|
|
4
|
+
var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
|
|
5
5
|
require('../unstable-core-do-not-import/rootConfig.js');
|
|
6
6
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
7
7
|
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
1
|
import { TRPCError } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
2
|
+
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
3
3
|
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
4
4
|
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
5
5
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type * as http from 'http';
|
|
3
|
+
export interface IncomingMessageWithBody extends http.IncomingMessage {
|
|
4
|
+
/**
|
|
5
|
+
* Many adapters will add a `body` property to the incoming message and pre-parse the body
|
|
6
|
+
*/
|
|
7
|
+
body?: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
11
|
+
*/
|
|
12
|
+
export declare function incomingMessageToRequest(req: http.IncomingMessage, opts: {
|
|
13
|
+
/**
|
|
14
|
+
* Max body size in bytes. If the body is larger than this, the request will be aborted
|
|
15
|
+
*/
|
|
16
|
+
maxBodySize: number | null;
|
|
17
|
+
}): Request;
|
|
18
|
+
//# sourceMappingURL=incomingMessageToRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA+CD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CA2BT"}
|