@trpc/server 11.18.1-canary.2 → 11.18.1-canary.30
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/index.cjs +16 -26
- package/dist/adapters/aws-lambda/index.d.cts +6 -16
- package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +6 -16
- package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
- package/dist/adapters/aws-lambda/index.mjs +13 -23
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +7 -16
- package/dist/adapters/express.d.cts +4 -11
- package/dist/adapters/express.d.cts.map +1 -1
- package/dist/adapters/express.d.mts +4 -11
- package/dist/adapters/express.d.mts.map +1 -1
- package/dist/adapters/express.mjs +6 -15
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +11 -24
- package/dist/adapters/fastify/index.d.cts +7 -14
- package/dist/adapters/fastify/index.d.cts.map +1 -1
- package/dist/adapters/fastify/index.d.mts +7 -14
- package/dist/adapters/fastify/index.d.mts.map +1 -1
- package/dist/adapters/fastify/index.mjs +10 -23
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +7 -12
- package/dist/adapters/fetch/index.d.cts +7 -15
- package/dist/adapters/fetch/index.d.cts.map +1 -1
- package/dist/adapters/fetch/index.d.mts +7 -15
- package/dist/adapters/fetch/index.d.mts.map +1 -1
- package/dist/adapters/fetch/index.mjs +6 -11
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +13 -3145
- package/dist/adapters/next-app-dir.d.cts +3 -12
- package/dist/adapters/next-app-dir.d.cts.map +1 -1
- package/dist/adapters/next-app-dir.d.mts +3 -12
- package/dist/adapters/next-app-dir.d.mts.map +1 -1
- package/dist/adapters/next-app-dir.mjs +31 -3165
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +8 -16
- package/dist/adapters/next.d.cts +5 -15
- package/dist/adapters/next.d.cts.map +1 -1
- package/dist/adapters/next.d.mts +5 -15
- package/dist/adapters/next.d.mts.map +1 -1
- package/dist/adapters/next.mjs +7 -15
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +3 -12
- package/dist/adapters/node-http/index.d.cts +1 -4
- package/dist/adapters/node-http/index.d.mts +1 -4
- package/dist/adapters/node-http/index.mjs +2 -12
- package/dist/adapters/standalone.cjs +21 -21
- package/dist/adapters/standalone.d.cts +9 -14
- package/dist/adapters/standalone.d.cts.map +1 -1
- package/dist/adapters/standalone.d.mts +9 -14
- package/dist/adapters/standalone.d.mts.map +1 -1
- package/dist/adapters/standalone.mjs +17 -19
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +3 -15
- package/dist/adapters/ws.d.cts +12 -17
- package/dist/adapters/ws.d.cts.map +1 -1
- package/dist/adapters/ws.d.mts +12 -17
- package/dist/adapters/ws.d.mts.map +1 -1
- package/dist/adapters/ws.mjs +2 -15
- package/dist/{codes-BfZsPdy-.cjs → codes-C6ZIq69A.cjs} +78 -74
- package/dist/{codes-DagpWZLc.mjs → codes-D5Ya6_Bi.mjs} +10 -4
- package/dist/codes-D5Ya6_Bi.mjs.map +1 -0
- package/dist/{contentTypeParsers-iAFF_pJG.cjs → contentTypeParsers-DUzXRHT1.cjs} +6 -8
- package/dist/{contentTypeParsers-SN4WL9ze.mjs → contentTypeParsers-KFMy_fwz.mjs} +3 -3
- package/dist/contentTypeParsers-KFMy_fwz.mjs.map +1 -0
- package/dist/getErrorShape-B0JBUs-i.mjs +209 -0
- package/dist/getErrorShape-B0JBUs-i.mjs.map +1 -0
- package/dist/getErrorShape-DeIapApr.cjs +272 -0
- package/dist/http.cjs +5 -9
- package/dist/http.d.cts +2 -3
- package/dist/http.d.mts +2 -3
- package/dist/http.mjs +4 -9
- package/dist/{index.d-DhhodpGb.d.mts → index-BHatz_Pu.d.cts} +3 -8
- package/dist/index-BHatz_Pu.d.cts.map +1 -0
- package/dist/{index.d-BiUz7kM_.d.cts → index-BMimGNYb.d.cts} +2 -5
- package/dist/index-BMimGNYb.d.cts.map +1 -0
- package/dist/{index.d-D4qZxQJh.d.mts → index-BMimGNYb.d.mts} +2 -5
- package/dist/index-BMimGNYb.d.mts.map +1 -0
- package/dist/{index.d-fBAdSX6g.d.cts → index-_jAhoJQ7.d.mts} +3 -8
- package/dist/index-_jAhoJQ7.d.mts.map +1 -0
- package/dist/index.cjs +5 -6
- package/dist/index.d.cts +10 -4
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +10 -4
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -6
- package/dist/{initTRPC-BRf4imah.mjs → initTRPC-B259os3T.mjs} +85 -83
- package/dist/initTRPC-B259os3T.mjs.map +1 -0
- package/dist/{initTRPC-_cqIfGlH.cjs → initTRPC-B7UdX-c3.cjs} +133 -132
- package/dist/{node-http-gyWQuCv2.mjs → node-http-BUlb5EdB.mjs} +29 -26
- package/dist/node-http-BUlb5EdB.mjs.map +1 -0
- package/dist/{node-http-bPWQbKlA.cjs → node-http-CikCqjt6.cjs} +48 -46
- package/dist/observable/index.cjs +4 -4
- package/dist/observable/index.d.cts +2 -2
- package/dist/observable/index.d.mts +2 -2
- package/dist/observable/index.mjs +3 -4
- package/dist/{observable-B1Nk6r1H.cjs → observable-CIyO2eSm.cjs} +28 -32
- package/dist/{observable-CUiPknO-.mjs → observable-CSprJVOf.mjs} +6 -10
- package/dist/observable-CSprJVOf.mjs.map +1 -0
- package/dist/{observable-BVzLuBs6.cjs → observable-D8mqXlHG.cjs} +34 -39
- package/dist/{observable-UMO3vUa_.mjs → observable-DwUFSuKv.mjs} +10 -12
- package/dist/observable-DwUFSuKv.mjs.map +1 -0
- package/dist/{parseTRPCMessage-7Ltmq-Fb.cjs → parseTRPCMessage-BxAIUx49.cjs} +14 -18
- package/dist/{parseTRPCMessage-CTow-umk.mjs → parseTRPCMessage-MJWDg1vX.mjs} +6 -9
- package/dist/parseTRPCMessage-MJWDg1vX.mjs.map +1 -0
- package/dist/{resolveResponse-BCkjJQIz.cjs → resolveResponse-DLpzHrPG.cjs} +507 -585
- package/dist/{resolveResponse-CdASWfAV.mjs → resolveResponse-JtMyT9TQ.mjs} +414 -491
- package/dist/resolveResponse-JtMyT9TQ.mjs.map +1 -0
- package/dist/rolldown-runtime-VH7oDXx4.cjs +28 -0
- package/dist/rpc.cjs +4 -4
- package/dist/rpc.d.cts +2 -3
- package/dist/rpc.d.mts +2 -3
- package/dist/rpc.mjs +3 -4
- package/dist/shared.cjs +3 -4
- package/dist/shared.d.cts +2 -4
- package/dist/shared.d.mts +2 -4
- package/dist/shared.mjs +2 -4
- package/dist/{tracked-DFxm8M2u.cjs → tracked-BQJb0ANk.cjs} +125 -142
- package/dist/{tracked-DWInO6EQ.mjs → tracked-D4jU_Hb3.mjs} +42 -58
- package/dist/tracked-D4jU_Hb3.mjs.map +1 -0
- package/dist/{unstable-core-do-not-import.d-BdVSvUCr.d.mts → unstable-core-do-not-import-B9ZnrQAU.d.cts} +37 -69
- package/dist/unstable-core-do-not-import-B9ZnrQAU.d.cts.map +1 -0
- package/dist/{unstable-core-do-not-import.d-Dh9CT5RO.d.cts → unstable-core-do-not-import-BK_OKrtM.d.mts} +37 -69
- package/dist/unstable-core-do-not-import-BK_OKrtM.d.mts.map +1 -0
- package/dist/unstable-core-do-not-import.cjs +33 -12
- package/dist/unstable-core-do-not-import.d.cts +2 -3
- package/dist/unstable-core-do-not-import.d.mts +2 -3
- package/dist/unstable-core-do-not-import.mjs +32 -10
- package/dist/unstable-core-do-not-import.mjs.map +1 -0
- package/dist/{ws-CTzlBSdd.cjs → ws-BMSSVFiW.cjs} +59 -65
- package/dist/{ws-BoiCYrkt.mjs → ws-C7ZOJJeA.mjs} +41 -46
- package/dist/ws-C7ZOJJeA.mjs.map +1 -0
- package/package.json +12 -12
- package/src/@trpc/server/index.ts +4 -0
- package/src/adapters/aws-lambda/getPlanner.ts +1 -2
- package/src/adapters/aws-lambda/index.ts +1 -2
- package/src/adapters/ws.ts +3 -2
- package/src/adapters/wsEncoder.ts +1 -1
- package/src/observable/behaviorSubject.ts +4 -2
- package/src/observable/types.ts +4 -2
- package/src/unstable-core-do-not-import/clientish/inferrable.ts +1 -4
- package/src/unstable-core-do-not-import/http/contentType.ts +1 -1
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +4 -9
- package/src/unstable-core-do-not-import/http/types.ts +8 -4
- package/src/unstable-core-do-not-import/initTRPC.ts +10 -10
- package/src/unstable-core-do-not-import/middleware.ts +3 -2
- package/src/unstable-core-do-not-import/procedure.ts +11 -11
- package/src/unstable-core-do-not-import/router.ts +4 -5
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +33 -34
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +2 -3
- package/src/unstable-core-do-not-import/stream/jsonl.ts +1 -2
- package/src/unstable-core-do-not-import/stream/sse.ts +18 -12
- package/src/unstable-core-do-not-import/stream/utils/disposable.ts +2 -2
- package/src/unstable-core-do-not-import/stream/utils/mergeAsyncIterables.ts +5 -2
- package/src/unstable-core-do-not-import/stream/utils/withPing.ts +1 -3
- package/src/unstable-core-do-not-import/transformer.ts +1 -4
- package/src/unstable-core-do-not-import/types.ts +9 -10
- package/dist/codes-DagpWZLc.mjs.map +0 -1
- package/dist/contentTypeParsers-SN4WL9ze.mjs.map +0 -1
- package/dist/getErrorShape-BPSzUA7W.mjs +0 -269
- package/dist/getErrorShape-BPSzUA7W.mjs.map +0 -1
- package/dist/getErrorShape-Ed1OwssN.cjs +0 -345
- package/dist/http-CWyjOa1l.mjs +0 -0
- package/dist/http-DXy3XyhL.cjs +0 -0
- package/dist/index.d-BiUz7kM_.d.cts.map +0 -1
- package/dist/index.d-CvZXeEyR.d.cts +0 -11
- package/dist/index.d-CvZXeEyR.d.cts.map +0 -1
- package/dist/index.d-D4qZxQJh.d.mts.map +0 -1
- package/dist/index.d-DhhodpGb.d.mts.map +0 -1
- package/dist/index.d-fBAdSX6g.d.cts.map +0 -1
- package/dist/index.d-vq_QHko2.d.mts +0 -11
- package/dist/index.d-vq_QHko2.d.mts.map +0 -1
- package/dist/initTRPC-BRf4imah.mjs.map +0 -1
- package/dist/node-http-gyWQuCv2.mjs.map +0 -1
- package/dist/observable-CUiPknO-.mjs.map +0 -1
- package/dist/observable-UMO3vUa_.mjs.map +0 -1
- package/dist/parseTRPCMessage-CTow-umk.mjs.map +0 -1
- package/dist/resolveResponse-CdASWfAV.mjs.map +0 -1
- package/dist/tracked-DWInO6EQ.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-9NNw8uQM.mjs +0 -31
- package/dist/unstable-core-do-not-import-9NNw8uQM.mjs.map +0 -1
- package/dist/unstable-core-do-not-import-fsjhEhgh.cjs +0 -35
- package/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts.map +0 -1
- package/dist/unstable-core-do-not-import.d-Dh9CT5RO.d.cts.map +0 -1
- package/dist/ws-BoiCYrkt.mjs.map +0 -1
package/dist/adapters/next.cjs
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const require_codes = require(
|
|
3
|
-
const
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
|
-
require('../unstable-core-do-not-import-fsjhEhgh.cjs');
|
|
8
|
-
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
-
require('../initTRPC-_cqIfGlH.cjs');
|
|
10
|
-
const require_node_http = require('../node-http-bPWQbKlA.cjs');
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_codes = require("../codes-C6ZIq69A.cjs");
|
|
3
|
+
const require_getErrorShape = require("../getErrorShape-DeIapApr.cjs");
|
|
4
|
+
const require_tracked = require("../tracked-BQJb0ANk.cjs");
|
|
5
|
+
const require_node_http = require("../node-http-CikCqjt6.cjs");
|
|
12
6
|
//#region src/adapters/next.ts
|
|
13
|
-
var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
14
7
|
function createNextApiHandler(opts) {
|
|
15
8
|
return async (req, res) => {
|
|
16
9
|
let path = "";
|
|
@@ -23,18 +16,17 @@ function createNextApiHandler(opts) {
|
|
|
23
16
|
code: "INTERNAL_SERVER_ERROR"
|
|
24
17
|
});
|
|
25
18
|
});
|
|
26
|
-
await require_node_http.nodeHTTPRequestHandler(
|
|
19
|
+
await require_node_http.nodeHTTPRequestHandler(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
27
20
|
req,
|
|
28
21
|
res,
|
|
29
22
|
path
|
|
30
23
|
}));
|
|
31
|
-
}).catch(require_node_http.internal_exceptionHandler(
|
|
24
|
+
}).catch(require_node_http.internal_exceptionHandler(require_getErrorShape._objectSpread2({
|
|
32
25
|
req,
|
|
33
26
|
res,
|
|
34
27
|
path
|
|
35
28
|
}, opts)));
|
|
36
29
|
};
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
//#endregion
|
|
40
|
-
exports.createNextApiHandler = createNextApiHandler;
|
|
32
|
+
exports.createNextApiHandler = createNextApiHandler;
|
package/dist/adapters/next.d.cts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-CvZXeEyR.cjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from "../index.d-fBAdSX6g.cjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-B9ZnrQAU.cjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-BHatz_Pu.cjs";
|
|
5
3
|
import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
|
|
6
|
-
|
|
7
4
|
//#region src/adapters/next.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Preventing "TypeScript where it's tough not to get "The inferred type of 'xxxx' cannot be named without a reference to [...]"
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
15
|
-
//# sourceMappingURL=next.d.ts.map
|
|
16
|
-
|
|
5
|
+
export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest$1, NextApiResponse$1>;
|
|
6
|
+
export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
17
7
|
//#endregion
|
|
18
|
-
export {
|
|
8
|
+
export type { NextApiHandler, NextApiRequest, NextApiResponse };
|
|
19
9
|
//# sourceMappingURL=next.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.cts","names":[],"sources":["../../src/adapters/next.ts"],"
|
|
1
|
+
{"version":3,"file":"next.d.cts","names":[],"sources":["../../src/adapters/next.ts"],"mappings":";;;;YAsBY,2BAA2B,+BACrC,kBACA;wBAQc,qBAAqB,gBAAgB,WACnD,MAAM,uBAAuB,SAAS,kBAAgB,qBACrD"}
|
package/dist/adapters/next.d.mts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-vq_QHko2.mjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions } from "../index.d-DhhodpGb.mjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-BK_OKrtM.mjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, o as NodeHTTPCreateContextFnOptions } from "../index-_jAhoJQ7.mjs";
|
|
5
3
|
import { NextApiHandler, NextApiHandler as NextApiHandler$1, NextApiRequest, NextApiRequest as NextApiRequest$1, NextApiResponse, NextApiResponse as NextApiResponse$1 } from "next";
|
|
6
|
-
|
|
7
4
|
//#region src/adapters/next.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Preventing "TypeScript where it's tough not to get "The inferred type of 'xxxx' cannot be named without a reference to [...]"
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
15
|
-
//# sourceMappingURL=next.d.ts.map
|
|
16
|
-
|
|
5
|
+
export type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<NextApiRequest$1, NextApiResponse$1>;
|
|
6
|
+
export declare function createNextApiHandler<TRouter extends AnyRouter>(opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest$1, NextApiResponse$1>): NextApiHandler$1;
|
|
17
7
|
//#endregion
|
|
18
|
-
export {
|
|
8
|
+
export type { NextApiHandler, NextApiRequest, NextApiResponse };
|
|
19
9
|
//# sourceMappingURL=next.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.mts","names":[],"sources":["../../src/adapters/next.ts"],"
|
|
1
|
+
{"version":3,"file":"next.d.mts","names":[],"sources":["../../src/adapters/next.ts"],"mappings":";;;;YAsBY,2BAA2B,+BACrC,kBACA;wBAQc,qBAAqB,gBAAgB,WACnD,MAAM,uBAAuB,SAAS,kBAAgB,qBACrD"}
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { TRPCError } from "../tracked-
|
|
4
|
-
import "../
|
|
5
|
-
import "../resolveResponse-CdASWfAV.mjs";
|
|
6
|
-
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
|
-
import "../unstable-core-do-not-import-9NNw8uQM.mjs";
|
|
8
|
-
import "../observable-UMO3vUa_.mjs";
|
|
9
|
-
import "../initTRPC-BRf4imah.mjs";
|
|
10
|
-
import { internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-gyWQuCv2.mjs";
|
|
11
|
-
|
|
1
|
+
import { p as run } from "../codes-D5Ya6_Bi.mjs";
|
|
2
|
+
import { n as _objectSpread2 } from "../getErrorShape-B0JBUs-i.mjs";
|
|
3
|
+
import { m as TRPCError } from "../tracked-D4jU_Hb3.mjs";
|
|
4
|
+
import { n as nodeHTTPRequestHandler, t as internal_exceptionHandler } from "../node-http-BUlb5EdB.mjs";
|
|
12
5
|
//#region src/adapters/next.ts
|
|
13
|
-
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
14
6
|
function createNextApiHandler(opts) {
|
|
15
7
|
return async (req, res) => {
|
|
16
8
|
let path = "";
|
|
@@ -23,19 +15,19 @@ function createNextApiHandler(opts) {
|
|
|
23
15
|
code: "INTERNAL_SERVER_ERROR"
|
|
24
16
|
});
|
|
25
17
|
});
|
|
26
|
-
await nodeHTTPRequestHandler((
|
|
18
|
+
await nodeHTTPRequestHandler(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
27
19
|
req,
|
|
28
20
|
res,
|
|
29
21
|
path
|
|
30
22
|
}));
|
|
31
|
-
}).catch(internal_exceptionHandler((
|
|
23
|
+
}).catch(internal_exceptionHandler(_objectSpread2({
|
|
32
24
|
req,
|
|
33
25
|
res,
|
|
34
26
|
path
|
|
35
27
|
}, opts)));
|
|
36
28
|
};
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
//#endregion
|
|
40
31
|
export { createNextApiHandler };
|
|
32
|
+
|
|
41
33
|
//# sourceMappingURL=next.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.mjs","names":[
|
|
1
|
+
{"version":3,"file":"next.mjs","names":[],"sources":["../../src/adapters/next.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\nimport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n// @trpc/server\nimport type { AnyRouter } from '../@trpc/server';\n// @trpc/server\nimport { TRPCError } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n} from './node-http';\nimport { internal_exceptionHandler, nodeHTTPRequestHandler } from './node-http';\n\nexport type CreateNextContextOptions = NodeHTTPCreateContextFnOptions<\n NextApiRequest,\n NextApiResponse\n>;\n\n/**\n * Preventing \"TypeScript where it's tough not to get \"The inferred type of 'xxxx' cannot be named without a reference to [...]\"\n */\nexport type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';\n\nexport function createNextApiHandler<TRouter extends AnyRouter>(\n opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>,\n): NextApiHandler {\n return async (req, res) => {\n let path = '';\n\n await run(async () => {\n path = run(() => {\n if (typeof req.query['trpc'] === 'string') {\n return req.query['trpc'];\n }\n if (Array.isArray(req.query['trpc'])) {\n return req.query['trpc'].join('/');\n }\n throw new TRPCError({\n message:\n 'Query \"trpc\" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',\n code: 'INTERNAL_SERVER_ERROR',\n });\n });\n\n await nodeHTTPRequestHandler({\n ...(opts as any),\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n"],"mappings":";;;;;AAgCA,SAAgB,qBACd,MACgB;CAChB,OAAO,OAAO,KAAK,QAAQ;EACzB,IAAI,OAAO;EAEX,MAAM,IAAI,YAAY;GACpB,OAAO,UAAU;IACf,IAAI,OAAO,IAAI,MAAM,YAAY,UAC/B,OAAO,IAAI,MAAM;IAEnB,IAAI,MAAM,QAAQ,IAAI,MAAM,OAAO,GACjC,OAAO,IAAI,MAAM,OAAO,CAAC,KAAK,GAAG;IAEnC,MAAM,IAAI,UAAU;KAClB,SACE;KACF,MAAM;IACR,CAAC;GACH,CAAC;GAED,MAAM,uBAAA,eAAA,eAAA,CAAA,GACA,IAAA,GAAA,CAAA,GAAA;IACJ;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require('../../tracked-DFxm8M2u.cjs');
|
|
4
|
-
require('../../parseTRPCMessage-7Ltmq-Fb.cjs');
|
|
5
|
-
require('../../resolveResponse-BCkjJQIz.cjs');
|
|
6
|
-
require('../../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
|
-
require('../../unstable-core-do-not-import-fsjhEhgh.cjs');
|
|
8
|
-
require('../../observable-B1Nk6r1H.cjs');
|
|
9
|
-
require('../../initTRPC-_cqIfGlH.cjs');
|
|
10
|
-
const require_node_http = require('../../node-http-bPWQbKlA.cjs');
|
|
11
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_node_http = require("../../node-http-CikCqjt6.cjs");
|
|
12
3
|
exports.createURL = require_node_http.createURL;
|
|
13
4
|
exports.incomingMessageToRequest = require_node_http.incomingMessageToRequest;
|
|
14
5
|
exports.internal_exceptionHandler = require_node_http.internal_exceptionHandler;
|
|
15
|
-
exports.nodeHTTPRequestHandler = require_node_http.nodeHTTPRequestHandler;
|
|
6
|
+
exports.nodeHTTPRequestHandler = require_node_http.nodeHTTPRequestHandler;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import "../../index
|
|
2
|
-
import "../../unstable-core-do-not-import.d-Dh9CT5RO.cjs";
|
|
3
|
-
import "../../index.d-CvZXeEyR.cjs";
|
|
4
|
-
import { NodeHTTPCreateContextFn, NodeHTTPCreateContextFnOptions, NodeHTTPCreateContextOption, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse, createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler } from "../../index.d-fBAdSX6g.cjs";
|
|
1
|
+
import { a as NodeHTTPCreateContextFn, c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, i as nodeHTTPRequestHandler, l as NodeHTTPRequest, n as incomingMessageToRequest, o as NodeHTTPCreateContextFnOptions, r as internal_exceptionHandler, s as NodeHTTPCreateContextOption, t as createURL, u as NodeHTTPRequestHandlerOptions } from "../../index-BHatz_Pu.cjs";
|
|
5
2
|
export { NodeHTTPCreateContextFn, NodeHTTPCreateContextFnOptions, NodeHTTPCreateContextOption, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse, createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import "../../index
|
|
2
|
-
import "../../unstable-core-do-not-import.d-BdVSvUCr.mjs";
|
|
3
|
-
import "../../index.d-vq_QHko2.mjs";
|
|
4
|
-
import { NodeHTTPCreateContextFn, NodeHTTPCreateContextFnOptions, NodeHTTPCreateContextOption, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse, createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler } from "../../index.d-DhhodpGb.mjs";
|
|
1
|
+
import { a as NodeHTTPCreateContextFn, c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, i as nodeHTTPRequestHandler, l as NodeHTTPRequest, n as incomingMessageToRequest, o as NodeHTTPCreateContextFnOptions, r as internal_exceptionHandler, s as NodeHTTPCreateContextOption, t as createURL, u as NodeHTTPRequestHandlerOptions } from "../../index-_jAhoJQ7.mjs";
|
|
5
2
|
export { NodeHTTPCreateContextFn, NodeHTTPCreateContextFnOptions, NodeHTTPCreateContextOption, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPRequestHandlerOptions, NodeHTTPResponse, createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
|
|
3
|
-
import "../../tracked-DWInO6EQ.mjs";
|
|
4
|
-
import "../../parseTRPCMessage-CTow-umk.mjs";
|
|
5
|
-
import "../../resolveResponse-CdASWfAV.mjs";
|
|
6
|
-
import "../../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
|
-
import "../../unstable-core-do-not-import-9NNw8uQM.mjs";
|
|
8
|
-
import "../../observable-UMO3vUa_.mjs";
|
|
9
|
-
import "../../initTRPC-BRf4imah.mjs";
|
|
10
|
-
import { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler } from "../../node-http-gyWQuCv2.mjs";
|
|
11
|
-
|
|
12
|
-
export { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
1
|
+
import { i as incomingMessageToRequest, n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../../node-http-BUlb5EdB.mjs";
|
|
2
|
+
export { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
require(
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
require(
|
|
7
|
-
|
|
8
|
-
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
-
require('../initTRPC-_cqIfGlH.cjs');
|
|
10
|
-
const require_node_http = require('../node-http-bPWQbKlA.cjs');
|
|
11
|
-
const http = require_getErrorShape.__toESM(require("http"));
|
|
12
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-VH7oDXx4.cjs");
|
|
3
|
+
const require_codes = require("../codes-C6ZIq69A.cjs");
|
|
4
|
+
const require_getErrorShape = require("../getErrorShape-DeIapApr.cjs");
|
|
5
|
+
const require_node_http = require("../node-http-CikCqjt6.cjs");
|
|
6
|
+
let http = require("http");
|
|
7
|
+
http = require_rolldown_runtime.__toESM(http, 1);
|
|
13
8
|
//#region src/adapters/standalone.ts
|
|
14
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 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`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
15
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
15
18
|
function createHandler(opts) {
|
|
16
19
|
var _opts$basePath;
|
|
17
|
-
const
|
|
18
|
-
const sliceLength = basePath.length;
|
|
20
|
+
const sliceLength = ((_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/").length;
|
|
19
21
|
return (req, res) => {
|
|
20
22
|
let path = "";
|
|
21
23
|
require_codes.run(async () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await require_node_http.nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
24
|
+
path = require_node_http.createURL(req).pathname.slice(sliceLength);
|
|
25
|
+
await require_node_http.nodeHTTPRequestHandler(require_getErrorShape._objectSpread2(require_getErrorShape._objectSpread2({}, opts), {}, {
|
|
25
26
|
req,
|
|
26
27
|
res,
|
|
27
28
|
path
|
|
28
29
|
}));
|
|
29
|
-
}).catch(require_node_http.internal_exceptionHandler(
|
|
30
|
+
}).catch(require_node_http.internal_exceptionHandler(require_getErrorShape._objectSpread2({
|
|
30
31
|
req,
|
|
31
32
|
res,
|
|
32
33
|
path
|
|
@@ -45,8 +46,7 @@ function createHTTPServer(opts) {
|
|
|
45
46
|
function createHTTP2Handler(opts) {
|
|
46
47
|
return createHandler(opts);
|
|
47
48
|
}
|
|
48
|
-
|
|
49
49
|
//#endregion
|
|
50
50
|
exports.createHTTP2Handler = createHTTP2Handler;
|
|
51
51
|
exports.createHTTPHandler = createHTTPHandler;
|
|
52
|
-
exports.createHTTPServer = createHTTPServer;
|
|
52
|
+
exports.createHTTPServer = createHTTPServer;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-CvZXeEyR.cjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPResponse } from "../index.d-fBAdSX6g.cjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-B9ZnrQAU.cjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, l as NodeHTTPRequest, o as NodeHTTPCreateContextFnOptions } from "../index-BHatz_Pu.cjs";
|
|
5
3
|
import http from "http";
|
|
6
4
|
import * as http2 from "http2";
|
|
7
|
-
|
|
8
5
|
//#region src/adapters/standalone.d.ts
|
|
9
|
-
|
|
10
6
|
type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
11
7
|
/**
|
|
12
8
|
* The base path to handle requests for.
|
|
@@ -18,16 +14,15 @@ type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHT
|
|
|
18
14
|
*/
|
|
19
15
|
basePath?: string;
|
|
20
16
|
};
|
|
21
|
-
type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
|
22
|
-
type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
17
|
+
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
|
18
|
+
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
23
19
|
/**
|
|
24
20
|
* @internal
|
|
25
21
|
*/
|
|
26
|
-
declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
|
|
27
|
-
declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
28
|
-
type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
29
|
-
type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
30
|
-
declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
|
|
22
|
+
export declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
|
|
23
|
+
export declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
24
|
+
export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
25
|
+
export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
26
|
+
export declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
|
|
31
27
|
//#endregion
|
|
32
|
-
export { CreateHTTP2ContextOptions, CreateHTTP2HandlerOptions, CreateHTTPContextOptions, CreateHTTPHandlerOptions, createHTTP2Handler, createHTTPHandler, createHTTPServer };
|
|
33
28
|
//# sourceMappingURL=standalone.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.cts","names":[],"sources":["../../src/adapters/standalone.ts"],"
|
|
1
|
+
{"version":3,"file":"standalone.d.cts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;KA6BK,yBACH,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS,UAAU;;;;;;;;;EAS5C;;YAIU,yBAAyB,gBAAgB,aACnD,yBAAyB,SAAS,KAAK,iBAAiB,KAAK;YAEnD,2BAA2B,+BACrC,KAAK,iBACL,KAAK;;;;wBA0CS,kBAAkB,gBAAgB,WAChD,MAAM,yBAAyB,WAC9B,KAAK;wBAIQ,iBAAiB,gBAAgB,WAC/C,MAAM,yBAAyB,WAAQ,KAAA,cAAA,KAAA,wBAAA,KAAA;YAM7B,0BAA0B,gBAAgB,aACpD,yBACE,SACA,MAAM,oBACN,MAAM;YAGE,4BAA4B,+BACtC,MAAM,oBACN,MAAM;wBAGQ,mBAAmB,MAAM,0BAA0B,cAAU,KAAA,MAAA,oBAAA,KAAA,MAAA,oBAAA,MAAA"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-vq_QHko2.mjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions, NodeHTTPHandlerOptions, NodeHTTPRequest, NodeHTTPResponse } from "../index.d-DhhodpGb.mjs";
|
|
1
|
+
import { J as AnyRouter } from "../unstable-core-do-not-import-BK_OKrtM.mjs";
|
|
2
|
+
import { c as NodeHTTPHandlerOptions, d as NodeHTTPResponse, l as NodeHTTPRequest, o as NodeHTTPCreateContextFnOptions } from "../index-_jAhoJQ7.mjs";
|
|
5
3
|
import http from "http";
|
|
6
4
|
import * as http2 from "http2";
|
|
7
|
-
|
|
8
5
|
//#region src/adapters/standalone.d.ts
|
|
9
|
-
|
|
10
6
|
type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHTTPRequest, TResponse extends NodeHTTPResponse> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {
|
|
11
7
|
/**
|
|
12
8
|
* The base path to handle requests for.
|
|
@@ -18,16 +14,15 @@ type StandaloneHandlerOptions<TRouter extends AnyRouter, TRequest extends NodeHT
|
|
|
18
14
|
*/
|
|
19
15
|
basePath?: string;
|
|
20
16
|
};
|
|
21
|
-
type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
|
22
|
-
type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
17
|
+
export type CreateHTTPHandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;
|
|
18
|
+
export type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<http.IncomingMessage, http.ServerResponse>;
|
|
23
19
|
/**
|
|
24
20
|
* @internal
|
|
25
21
|
*/
|
|
26
|
-
declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
|
|
27
|
-
declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
28
|
-
type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
29
|
-
type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
30
|
-
declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
|
|
22
|
+
export declare function createHTTPHandler<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.RequestListener;
|
|
23
|
+
export declare function createHTTPServer<TRouter extends AnyRouter>(opts: CreateHTTPHandlerOptions<TRouter>): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
24
|
+
export type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> = StandaloneHandlerOptions<TRouter, http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
25
|
+
export type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<http2.Http2ServerRequest, http2.Http2ServerResponse>;
|
|
26
|
+
export declare function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>): (req: http2.Http2ServerRequest, res: http2.Http2ServerResponse<http2.Http2ServerRequest>) => void;
|
|
31
27
|
//#endregion
|
|
32
|
-
export { CreateHTTP2ContextOptions, CreateHTTP2HandlerOptions, CreateHTTPContextOptions, CreateHTTPHandlerOptions, createHTTP2Handler, createHTTPHandler, createHTTPServer };
|
|
33
28
|
//# sourceMappingURL=standalone.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.mts","names":[],"sources":["../../src/adapters/standalone.ts"],"
|
|
1
|
+
{"version":3,"file":"standalone.d.mts","names":[],"sources":["../../src/adapters/standalone.ts"],"mappings":";;;;;KA6BK,yBACH,gBAAgB,WAChB,iBAAiB,iBACjB,kBAAkB,oBAChB,uBAAuB,SAAS,UAAU;;;;;;;;;EAS5C;;YAIU,yBAAyB,gBAAgB,aACnD,yBAAyB,SAAS,KAAK,iBAAiB,KAAK;YAEnD,2BAA2B,+BACrC,KAAK,iBACL,KAAK;;;;wBA0CS,kBAAkB,gBAAgB,WAChD,MAAM,yBAAyB,WAC9B,KAAK;wBAIQ,iBAAiB,gBAAgB,WAC/C,MAAM,yBAAyB,WAAQ,KAAA,cAAA,KAAA,wBAAA,KAAA;YAM7B,0BAA0B,gBAAgB,aACpD,yBACE,SACA,MAAM,oBACN,MAAM;YAGE,4BAA4B,+BACtC,MAAM,oBACN,MAAM;wBAGQ,mBAAmB,MAAM,0BAA0B,cAAU,KAAA,MAAA,oBAAA,KAAA,MAAA,oBAAA,MAAA"}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "../
|
|
4
|
-
import "../parseTRPCMessage-CTow-umk.mjs";
|
|
5
|
-
import "../resolveResponse-CdASWfAV.mjs";
|
|
6
|
-
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
|
-
import "../unstable-core-do-not-import-9NNw8uQM.mjs";
|
|
8
|
-
import "../observable-UMO3vUa_.mjs";
|
|
9
|
-
import "../initTRPC-BRf4imah.mjs";
|
|
10
|
-
import { createURL, internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-gyWQuCv2.mjs";
|
|
1
|
+
import { p as run } from "../codes-D5Ya6_Bi.mjs";
|
|
2
|
+
import { n as _objectSpread2 } from "../getErrorShape-B0JBUs-i.mjs";
|
|
3
|
+
import { n as nodeHTTPRequestHandler, r as createURL, t as internal_exceptionHandler } from "../node-http-BUlb5EdB.mjs";
|
|
11
4
|
import http from "http";
|
|
12
|
-
|
|
13
5
|
//#region src/adapters/standalone.ts
|
|
14
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 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`
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { AnyTRPCRouter } from '@trpc/server'
|
|
12
|
+
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
15
|
function createHandler(opts) {
|
|
16
16
|
var _opts$basePath;
|
|
17
|
-
const
|
|
18
|
-
const sliceLength = basePath.length;
|
|
17
|
+
const sliceLength = ((_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/").length;
|
|
19
18
|
return (req, res) => {
|
|
20
19
|
let path = "";
|
|
21
20
|
run(async () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
await nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
21
|
+
path = createURL(req).pathname.slice(sliceLength);
|
|
22
|
+
await nodeHTTPRequestHandler(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
25
23
|
req,
|
|
26
24
|
res,
|
|
27
25
|
path
|
|
28
26
|
}));
|
|
29
|
-
}).catch(internal_exceptionHandler((
|
|
27
|
+
}).catch(internal_exceptionHandler(_objectSpread2({
|
|
30
28
|
req,
|
|
31
29
|
res,
|
|
32
30
|
path
|
|
@@ -45,7 +43,7 @@ function createHTTPServer(opts) {
|
|
|
45
43
|
function createHTTP2Handler(opts) {
|
|
46
44
|
return createHandler(opts);
|
|
47
45
|
}
|
|
48
|
-
|
|
49
46
|
//#endregion
|
|
50
47
|
export { createHTTP2Handler, createHTTPHandler, createHTTPServer };
|
|
48
|
+
|
|
51
49
|
//# sourceMappingURL=standalone.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.mjs","names":[
|
|
1
|
+
{"version":3,"file":"standalone.mjs","names":[],"sources":["../../src/adapters/standalone.ts"],"sourcesContent":["/**\n * 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`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n\nimport http from 'http';\n// --- http2 ---\nimport type * as http2 from 'http2';\n// @trpc/server\nimport { type AnyRouter } from '../@trpc/server';\n// eslint-disable-next-line no-restricted-imports\nimport { run } from '../unstable-core-do-not-import';\nimport type {\n NodeHTTPCreateContextFnOptions,\n NodeHTTPHandlerOptions,\n NodeHTTPRequest,\n NodeHTTPResponse,\n} from './node-http';\nimport {\n createURL,\n internal_exceptionHandler,\n nodeHTTPRequestHandler,\n} from './node-http';\n\ntype StandaloneHandlerOptions<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n> = NodeHTTPHandlerOptions<TRouter, TRequest, TResponse> & {\n /**\n * The base path to handle requests for.\n * This will be sliced from the beginning of the request path\n * (Do not miss including the trailing slash)\n * @default '/'\n * @example '/trpc/'\n * @example '/trpc/api/'\n */\n basePath?: string;\n};\n\n// --- http1 ---\nexport type CreateHTTPHandlerOptions<TRouter extends AnyRouter> =\n StandaloneHandlerOptions<TRouter, http.IncomingMessage, http.ServerResponse>;\n\nexport type CreateHTTPContextOptions = NodeHTTPCreateContextFnOptions<\n http.IncomingMessage,\n http.ServerResponse\n>;\n\nfunction createHandler<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n>(\n opts: StandaloneHandlerOptions<TRouter, TRequest, TResponse>,\n): (req: TRequest, res: TResponse) => void {\n const basePath = opts.basePath ?? '/';\n const sliceLength = basePath.length;\n\n return (req, res) => {\n let path = '';\n\n run(async () => {\n const url = createURL(req);\n\n // get procedure(s) path and remove the leading slash\n path = url.pathname.slice(sliceLength);\n\n await nodeHTTPRequestHandler({\n ...(opts as any),\n req,\n res,\n path,\n });\n }).catch(\n internal_exceptionHandler({\n req,\n res,\n path,\n ...opts,\n }),\n );\n };\n}\n\n/**\n * @internal\n */\nexport function createHTTPHandler<TRouter extends AnyRouter>(\n opts: CreateHTTPHandlerOptions<TRouter>,\n): http.RequestListener {\n return createHandler(opts);\n}\n\nexport function createHTTPServer<TRouter extends AnyRouter>(\n opts: CreateHTTPHandlerOptions<TRouter>,\n) {\n return http.createServer(createHTTPHandler(opts));\n}\n\n// --- http2 ---\nexport type CreateHTTP2HandlerOptions<TRouter extends AnyRouter> =\n StandaloneHandlerOptions<\n TRouter,\n http2.Http2ServerRequest,\n http2.Http2ServerResponse\n >;\n\nexport type CreateHTTP2ContextOptions = NodeHTTPCreateContextFnOptions<\n http2.Http2ServerRequest,\n http2.Http2ServerResponse\n>;\n\nexport function createHTTP2Handler(opts: CreateHTTP2HandlerOptions<AnyRouter>) {\n return createHandler(opts);\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAS,cAKP,MACyC;;CAEzC,MAAM,gBAAA,iBADW,KAAK,cAAA,QAAA,mBAAA,KAAA,IAAA,iBAAY,IAAA,CACL;CAE7B,QAAQ,KAAK,QAAQ;EACnB,IAAI,OAAO;EAEX,IAAI,YAAY;GAId,OAHY,UAAU,GAGb,CAAC,CAAC,SAAS,MAAM,WAAW;GAErC,MAAM,uBAAA,eAAA,eAAA,CAAA,GACA,IAAA,GAAA,CAAA,GAAA;IACJ;IACA;IACA;GACF,CAAA,CAAC;EACH,CAAC,CAAC,CAAC,MACD,0BAAA,eAAA;GACE;GACA;GACA;EACG,GAAA,IACL,CAAC,CACH;CACF;AACF;;;;AAKA,SAAgB,kBACd,MACsB;CACtB,OAAO,cAAc,IAAI;AAC3B;AAEA,SAAgB,iBACd,MACA;CACA,OAAO,KAAK,aAAa,kBAAkB,IAAI,CAAC;AAClD;AAeA,SAAgB,mBAAmB,MAA4C;CAC7E,OAAO,cAAc,IAAI;AAC3B"}
|
package/dist/adapters/ws.cjs
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
require(
|
|
3
|
-
require('../tracked-DFxm8M2u.cjs');
|
|
4
|
-
require('../parseTRPCMessage-7Ltmq-Fb.cjs');
|
|
5
|
-
require('../resolveResponse-BCkjJQIz.cjs');
|
|
6
|
-
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
|
-
require('../unstable-core-do-not-import-fsjhEhgh.cjs');
|
|
8
|
-
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
-
require('../initTRPC-_cqIfGlH.cjs');
|
|
10
|
-
require('../http-DXy3XyhL.cjs');
|
|
11
|
-
require('../node-http-bPWQbKlA.cjs');
|
|
12
|
-
require('../observable-BVzLuBs6.cjs');
|
|
13
|
-
const require_ws = require('../ws-CTzlBSdd.cjs');
|
|
14
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_ws = require("../ws-BMSSVFiW.cjs");
|
|
15
3
|
exports.applyWSSHandler = require_ws.applyWSSHandler;
|
|
16
4
|
exports.getWSConnectionHandler = require_ws.getWSConnectionHandler;
|
|
17
5
|
exports.handleKeepAlive = require_ws.handleKeepAlive;
|
|
18
|
-
exports.jsonEncoder = require_ws.jsonEncoder;
|
|
6
|
+
exports.jsonEncoder = require_ws.jsonEncoder;
|
package/dist/adapters/ws.d.cts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
3
|
-
import "../index.d-CvZXeEyR.cjs";
|
|
4
|
-
import { NodeHTTPCreateContextFnOptions } from "../index.d-fBAdSX6g.cjs";
|
|
1
|
+
import { J as AnyRouter, ft as inferRouterContext, gn as BaseHandlerOptions, ii as MaybePromise, yt as CreateContextCallback } from "../unstable-core-do-not-import-B9ZnrQAU.cjs";
|
|
2
|
+
import { o as NodeHTTPCreateContextFnOptions } from "../index-BHatz_Pu.cjs";
|
|
5
3
|
import { IncomingMessage } from "http";
|
|
6
4
|
import ws from "ws";
|
|
7
|
-
|
|
8
5
|
//#region src/adapters/wsEncoder.d.ts
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* Encoder for WebSocket wire format.
|
|
12
8
|
* Encodes outgoing messages and decodes incoming messages.
|
|
@@ -21,7 +17,7 @@ import ws from "ws";
|
|
|
21
17
|
*/
|
|
22
18
|
interface Encoder {
|
|
23
19
|
/** Encode data for transmission over the wire */
|
|
24
|
-
encode(data: unknown): string | Uint8Array
|
|
20
|
+
encode(data: unknown): string | Uint8Array<ArrayBuffer>;
|
|
25
21
|
/** Decode data received from the wire */
|
|
26
22
|
decode(data: string | ArrayBuffer | Uint8Array): unknown;
|
|
27
23
|
}
|
|
@@ -29,23 +25,22 @@ interface Encoder {
|
|
|
29
25
|
* Default JSON encoder - used when no encoder is specified.
|
|
30
26
|
* This maintains backwards compatibility with existing behavior.
|
|
31
27
|
*/
|
|
32
|
-
declare const jsonEncoder: Encoder;
|
|
33
|
-
//# sourceMappingURL=wsEncoder.d.ts.map
|
|
28
|
+
export declare const jsonEncoder: Encoder;
|
|
34
29
|
//#endregion
|
|
35
30
|
//#region src/adapters/ws.d.ts
|
|
36
31
|
/**
|
|
37
32
|
* @public
|
|
38
33
|
*/
|
|
39
|
-
type CreateWSSContextFnOptions = NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>;
|
|
34
|
+
export type CreateWSSContextFnOptions = NodeHTTPCreateContextFnOptions<IncomingMessage, ws.WebSocket>;
|
|
40
35
|
/**
|
|
41
36
|
* @public
|
|
42
37
|
*/
|
|
43
|
-
type CreateWSSContextFn<TRouter extends AnyRouter> = (opts: CreateWSSContextFnOptions) => MaybePromise<inferRouterContext<TRouter>>;
|
|
44
|
-
type WSConnectionHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<TRouter, IncomingMessage> & CreateContextCallback<inferRouterContext<TRouter>, CreateWSSContextFn<TRouter>>;
|
|
38
|
+
export type CreateWSSContextFn<TRouter extends AnyRouter> = (opts: CreateWSSContextFnOptions) => MaybePromise<inferRouterContext<TRouter>>;
|
|
39
|
+
export type WSConnectionHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<TRouter, IncomingMessage> & CreateContextCallback<inferRouterContext<TRouter>, CreateWSSContextFn<TRouter>>;
|
|
45
40
|
/**
|
|
46
41
|
* Web socket server handler
|
|
47
42
|
*/
|
|
48
|
-
type WSSHandlerOptions<TRouter extends AnyRouter> = WSConnectionHandlerOptions<TRouter> & {
|
|
43
|
+
export type WSSHandlerOptions<TRouter extends AnyRouter> = WSConnectionHandlerOptions<TRouter> & {
|
|
49
44
|
wss: ws.WebSocketServer;
|
|
50
45
|
prefix?: string;
|
|
51
46
|
keepAlive?: {
|
|
@@ -77,14 +72,14 @@ type WSSHandlerOptions<TRouter extends AnyRouter> = WSConnectionHandlerOptions<T
|
|
|
77
72
|
*/
|
|
78
73
|
experimental_encoder?: Encoder;
|
|
79
74
|
};
|
|
80
|
-
declare function getWSConnectionHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): (client: ws.WebSocket, req: IncomingMessage) => void;
|
|
75
|
+
export declare function getWSConnectionHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): (client: ws.WebSocket, req: IncomingMessage) => void;
|
|
81
76
|
/**
|
|
82
77
|
* Handle WebSocket keep-alive messages
|
|
83
78
|
*/
|
|
84
|
-
declare function handleKeepAlive(client: ws.WebSocket, pingMs?: number, pongWaitMs?: number): void;
|
|
85
|
-
declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
|
|
79
|
+
export declare function handleKeepAlive(client: ws.WebSocket, pingMs?: number, pongWaitMs?: number): void;
|
|
80
|
+
export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
|
|
86
81
|
broadcastReconnectNotification: () => void;
|
|
87
82
|
};
|
|
88
83
|
//#endregion
|
|
89
|
-
export {
|
|
84
|
+
export type { Encoder };
|
|
90
85
|
//# sourceMappingURL=ws.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.cts","names":[],"sources":["../../src/adapters/wsEncoder.ts","../../src/adapters/ws.ts"],"
|
|
1
|
+
{"version":3,"file":"ws.d.cts","names":[],"sources":["../../src/adapters/wsEncoder.ts","../../src/adapters/ws.ts"],"mappings":";;;;;;;;;;;;;;;;;UAYiB;;EAEf,OAAO,yBAAyB,WAAW;;EAE3C,OAAO,eAAe,cAAc;;;;;;qBAOzB,aAAa;;;;;;YC8Bd,4BAA4B,+BACtC,iBACA,GAAG;;;;YAMO,mBAAmB,gBAAgB,cAC7C,MAAM,8BACH,aAAa,mBAAmB;YAEzB,2BAA2B,gBAAgB,aACrD,mBAAmB,SAAS,mBAC1B,sBACE,mBAAmB,UACnB,mBAAmB;;;;YAMb,kBAAkB,gBAAgB,aAC5C,2BAA2B;EACzB,KAAK,GAAG;EACR;EACA;;;;;IAKE;;;;;IAKA;;;;;IAKA;;;;;;;EAOF;;;;;EAKA,uBAAuB;;wBAGX,uBAAuB,gBAAgB,WACrD,MAAM,kBAAkB,YAAQ,QAMhB,GAAG,WAAS,KAAO;;;;wBA4crB,gBACd,QAAQ,GAAG,WACX,iBACA;wBAmCc,gBAAgB,gBAAgB,WAC9C,MAAM,kBAAkB;EAatB"}
|