@trpc/server 11.4.1 → 11.4.2
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 +49 -42
- package/dist/adapters/aws-lambda/index.mjs +47 -40
- package/dist/adapters/aws-lambda/index.mjs.map +1 -1
- package/dist/adapters/express.cjs +14 -15
- package/dist/adapters/express.mjs +14 -15
- package/dist/adapters/express.mjs.map +1 -1
- package/dist/adapters/fastify/index.cjs +27 -28
- package/dist/adapters/fastify/index.mjs +27 -28
- package/dist/adapters/fastify/index.mjs.map +1 -1
- package/dist/adapters/fetch/index.cjs +18 -19
- package/dist/adapters/fetch/index.mjs +18 -19
- package/dist/adapters/fetch/index.mjs.map +1 -1
- package/dist/adapters/next-app-dir.cjs +57 -53
- package/dist/adapters/next-app-dir.mjs +15 -11
- package/dist/adapters/next-app-dir.mjs.map +1 -1
- package/dist/adapters/next.cjs +14 -15
- package/dist/adapters/next.mjs +14 -15
- package/dist/adapters/next.mjs.map +1 -1
- package/dist/adapters/node-http/index.cjs +8 -8
- package/dist/adapters/node-http/index.mjs +8 -8
- package/dist/adapters/standalone.cjs +17 -17
- package/dist/adapters/standalone.mjs +16 -16
- package/dist/adapters/standalone.mjs.map +1 -1
- package/dist/adapters/ws.cjs +10 -10
- package/dist/adapters/ws.mjs +10 -10
- package/dist/getErrorShape-DKiEF6Zc.cjs +339 -0
- package/dist/getErrorShape-Uhlrl4Bk.mjs +263 -0
- package/dist/getErrorShape-Uhlrl4Bk.mjs.map +1 -0
- package/dist/http.cjs +5 -5
- package/dist/http.mjs +5 -5
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{initTRPC-DjEpHmY2.cjs → initTRPC-IT4M4lu3.cjs} +83 -64
- package/dist/{initTRPC-COaJMShh.mjs → initTRPC-IT_6ZYJd.mjs} +84 -65
- package/dist/initTRPC-IT_6ZYJd.mjs.map +1 -0
- package/dist/{node-http-BUQnHuGI.mjs → node-http-Du8akt-R.mjs} +26 -23
- package/dist/{node-http-BUQnHuGI.mjs.map → node-http-Du8akt-R.mjs.map} +1 -1
- package/dist/{node-http-BPR68yI4.cjs → node-http-kIQEhZUH.cjs} +25 -22
- package/dist/observable/index.cjs +2 -2
- package/dist/observable/index.mjs +2 -2
- package/dist/{observable-BwdrSFZU.cjs → observable-B1Nk6r1H.cjs} +7 -4
- package/dist/{observable-C6qq2Ydk.cjs → observable-BVzLuBs6.cjs} +19 -7
- package/dist/{observable-CFXA_tyK.mjs → observable-CUiPknO-.mjs} +20 -8
- package/dist/{observable-CFXA_tyK.mjs.map → observable-CUiPknO-.mjs.map} +1 -1
- package/dist/{observable-B1orLHHI.mjs → observable-UMO3vUa_.mjs} +8 -5
- package/dist/{observable-B1orLHHI.mjs.map → observable-UMO3vUa_.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-CNyYMSRB.mjs → parseTRPCMessage-ByIHyFRz.mjs} +2 -2
- package/dist/{parseTRPCMessage-CNyYMSRB.mjs.map → parseTRPCMessage-ByIHyFRz.mjs.map} +1 -1
- package/dist/{parseTRPCMessage-ByQWigsq.cjs → parseTRPCMessage-snNQop7N.cjs} +1 -1
- package/dist/{resolveResponse-B2CuaT_1.cjs → resolveResponse-CVGbakBm.cjs} +664 -405
- package/dist/{resolveResponse-DPbYgJDD.mjs → resolveResponse-CzlbRpCI.mjs} +660 -389
- package/dist/resolveResponse-CzlbRpCI.mjs.map +1 -0
- package/dist/rpc.cjs +2 -2
- package/dist/rpc.mjs +2 -2
- package/dist/shared.cjs +2 -2
- package/dist/shared.mjs +2 -2
- package/dist/{tracked-Dl9sBZxY.cjs → tracked-HoF8L_mq.cjs} +30 -42
- package/dist/{tracked-GEWPoL0C.mjs → tracked-gU3ttYjg.mjs} +31 -43
- package/dist/{tracked-GEWPoL0C.mjs.map → tracked-gU3ttYjg.mjs.map} +1 -1
- package/dist/unstable-core-do-not-import.cjs +7 -7
- package/dist/unstable-core-do-not-import.mjs +7 -7
- package/dist/{utils-BHZJcBRv.mjs → utils-DdbbrDku.mjs} +1 -1
- package/dist/{utils-BHZJcBRv.mjs.map → utils-DdbbrDku.mjs.map} +1 -1
- package/dist/{ws-C2nEUNk_.cjs → ws-BhrWsMpl.cjs} +37 -26
- package/dist/{ws-eIVIMTrw.mjs → ws-Bn5rkP_I.mjs} +37 -26
- package/dist/{ws-eIVIMTrw.mjs.map → ws-Bn5rkP_I.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/getErrorShape-CsikfkAc.cjs +0 -201
- package/dist/getErrorShape-DyYil4aT.mjs +0 -149
- package/dist/getErrorShape-DyYil4aT.mjs.map +0 -1
- package/dist/initTRPC-COaJMShh.mjs.map +0 -1
- package/dist/resolveResponse-DPbYgJDD.mjs.map +0 -1
- /package/dist/{utils-DVO6HZiR.cjs → utils-BhNVZA-c.cjs} +0 -0
package/dist/adapters/next.cjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
require('../
|
|
2
|
-
require('../
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
require('../
|
|
1
|
+
const require_getErrorShape = require('../getErrorShape-DKiEF6Zc.cjs');
|
|
2
|
+
const require_tracked = require('../tracked-HoF8L_mq.cjs');
|
|
3
|
+
const require_utils = require('../utils-BhNVZA-c.cjs');
|
|
4
|
+
require('../parseTRPCMessage-snNQop7N.cjs');
|
|
5
|
+
require('../resolveResponse-CVGbakBm.cjs');
|
|
6
6
|
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
7
|
require('../unstable-core-do-not-import-DFQys1IC.cjs');
|
|
8
|
-
require('../observable-
|
|
9
|
-
require('../initTRPC-
|
|
10
|
-
const require_node_http = require('../node-http-
|
|
8
|
+
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
+
require('../initTRPC-IT4M4lu3.cjs');
|
|
10
|
+
const require_node_http = require('../node-http-kIQEhZUH.cjs');
|
|
11
11
|
|
|
12
12
|
//#region src/adapters/next.ts
|
|
13
|
+
var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
13
14
|
function createNextApiHandler(opts) {
|
|
14
15
|
return async (req, res) => {
|
|
15
16
|
let path = "";
|
|
@@ -22,18 +23,16 @@ function createNextApiHandler(opts) {
|
|
|
22
23
|
code: "INTERNAL_SERVER_ERROR"
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
|
-
await require_node_http.nodeHTTPRequestHandler({
|
|
26
|
-
...opts,
|
|
26
|
+
await require_node_http.nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
27
27
|
req,
|
|
28
28
|
res,
|
|
29
29
|
path
|
|
30
|
-
});
|
|
31
|
-
}).catch(require_node_http.internal_exceptionHandler({
|
|
30
|
+
}));
|
|
31
|
+
}).catch(require_node_http.internal_exceptionHandler((0, import_objectSpread2.default)({
|
|
32
32
|
req,
|
|
33
33
|
res,
|
|
34
|
-
path
|
|
35
|
-
|
|
36
|
-
}));
|
|
34
|
+
path
|
|
35
|
+
}, opts)));
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
|
package/dist/adapters/next.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import "../
|
|
1
|
+
import { __toESM, require_objectSpread2 } from "../getErrorShape-Uhlrl4Bk.mjs";
|
|
2
|
+
import { TRPCError } from "../tracked-gU3ttYjg.mjs";
|
|
3
|
+
import { run } from "../utils-DdbbrDku.mjs";
|
|
4
|
+
import "../parseTRPCMessage-ByIHyFRz.mjs";
|
|
5
|
+
import "../resolveResponse-CzlbRpCI.mjs";
|
|
6
6
|
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
7
|
import "../unstable-core-do-not-import-D89CaGtL.mjs";
|
|
8
|
-
import "../observable-
|
|
9
|
-
import "../initTRPC-
|
|
10
|
-
import { internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-
|
|
8
|
+
import "../observable-UMO3vUa_.mjs";
|
|
9
|
+
import "../initTRPC-IT_6ZYJd.mjs";
|
|
10
|
+
import { internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-Du8akt-R.mjs";
|
|
11
11
|
|
|
12
12
|
//#region src/adapters/next.ts
|
|
13
|
+
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
13
14
|
function createNextApiHandler(opts) {
|
|
14
15
|
return async (req, res) => {
|
|
15
16
|
let path = "";
|
|
@@ -22,18 +23,16 @@ function createNextApiHandler(opts) {
|
|
|
22
23
|
code: "INTERNAL_SERVER_ERROR"
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
|
-
await nodeHTTPRequestHandler({
|
|
26
|
-
...opts,
|
|
26
|
+
await nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
27
27
|
req,
|
|
28
28
|
res,
|
|
29
29
|
path
|
|
30
|
-
});
|
|
31
|
-
}).catch(internal_exceptionHandler({
|
|
30
|
+
}));
|
|
31
|
+
}).catch(internal_exceptionHandler((0, import_objectSpread2.default)({
|
|
32
32
|
req,
|
|
33
33
|
res,
|
|
34
|
-
path
|
|
35
|
-
|
|
36
|
-
}));
|
|
34
|
+
path
|
|
35
|
+
}, opts)));
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.mjs","names":["opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>"],"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":"
|
|
1
|
+
{"version":3,"file":"next.mjs","names":["opts: NodeHTTPHandlerOptions<TRouter, NextApiRequest, NextApiResponse>"],"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,qBACdA,MACgB;AAChB,QAAO,OAAO,KAAK,QAAQ;EACzB,IAAI,OAAO;AAEX,QAAM,IAAI,YAAY;AACpB,UAAO,IAAI,MAAM;AACf,eAAW,IAAI,MAAM,YAAY,SAC/B,QAAO,IAAI,MAAM;AAEnB,QAAI,MAAM,QAAQ,IAAI,MAAM,QAAQ,CAClC,QAAO,IAAI,MAAM,QAAQ,KAAK,IAAI;AAEpC,UAAM,IAAI,UAAU;KAClB,SACE;KACF,MAAM;IACP;GACF,EAAC;AAEF,SAAM,+FACA;IACJ;IACA;IACA;MACA;EACH,EAAC,CAAC,MACD;GACE;GACA;GACA;KACG,MACH,CACH;CACF;AACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require('../../
|
|
2
|
-
require('../../
|
|
3
|
-
require('../../
|
|
4
|
-
require('../../
|
|
5
|
-
require('../../
|
|
1
|
+
require('../../getErrorShape-DKiEF6Zc.cjs');
|
|
2
|
+
require('../../tracked-HoF8L_mq.cjs');
|
|
3
|
+
require('../../utils-BhNVZA-c.cjs');
|
|
4
|
+
require('../../parseTRPCMessage-snNQop7N.cjs');
|
|
5
|
+
require('../../resolveResponse-CVGbakBm.cjs');
|
|
6
6
|
require('../../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
7
|
require('../../unstable-core-do-not-import-DFQys1IC.cjs');
|
|
8
|
-
require('../../observable-
|
|
9
|
-
require('../../initTRPC-
|
|
10
|
-
const require_node_http = require('../../node-http-
|
|
8
|
+
require('../../observable-B1Nk6r1H.cjs');
|
|
9
|
+
require('../../initTRPC-IT4M4lu3.cjs');
|
|
10
|
+
const require_node_http = require('../../node-http-kIQEhZUH.cjs');
|
|
11
11
|
|
|
12
12
|
exports.createURL = require_node_http.createURL;
|
|
13
13
|
exports.incomingMessageToRequest = require_node_http.incomingMessageToRequest;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import "../../
|
|
3
|
-
import "../../
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
1
|
+
import "../../getErrorShape-Uhlrl4Bk.mjs";
|
|
2
|
+
import "../../tracked-gU3ttYjg.mjs";
|
|
3
|
+
import "../../utils-DdbbrDku.mjs";
|
|
4
|
+
import "../../parseTRPCMessage-ByIHyFRz.mjs";
|
|
5
|
+
import "../../resolveResponse-CzlbRpCI.mjs";
|
|
6
6
|
import "../../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
7
|
import "../../unstable-core-do-not-import-D89CaGtL.mjs";
|
|
8
|
-
import "../../observable-
|
|
9
|
-
import "../../initTRPC-
|
|
10
|
-
import { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler } from "../../node-http-
|
|
8
|
+
import "../../observable-UMO3vUa_.mjs";
|
|
9
|
+
import "../../initTRPC-IT_6ZYJd.mjs";
|
|
10
|
+
import { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler } from "../../node-http-Du8akt-R.mjs";
|
|
11
11
|
|
|
12
12
|
export { createURL, incomingMessageToRequest, internal_exceptionHandler, nodeHTTPRequestHandler };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
const
|
|
2
|
-
require('../
|
|
3
|
-
require('../
|
|
4
|
-
|
|
5
|
-
require('../
|
|
1
|
+
const require_getErrorShape = require('../getErrorShape-DKiEF6Zc.cjs');
|
|
2
|
+
require('../tracked-HoF8L_mq.cjs');
|
|
3
|
+
const require_utils = require('../utils-BhNVZA-c.cjs');
|
|
4
|
+
require('../parseTRPCMessage-snNQop7N.cjs');
|
|
5
|
+
require('../resolveResponse-CVGbakBm.cjs');
|
|
6
6
|
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
7
|
require('../unstable-core-do-not-import-DFQys1IC.cjs');
|
|
8
|
-
require('../observable-
|
|
9
|
-
require('../initTRPC-
|
|
10
|
-
const require_node_http = require('../node-http-
|
|
11
|
-
const http =
|
|
8
|
+
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
+
require('../initTRPC-IT4M4lu3.cjs');
|
|
10
|
+
const require_node_http = require('../node-http-kIQEhZUH.cjs');
|
|
11
|
+
const http = require_getErrorShape.__toESM(require("http"));
|
|
12
12
|
|
|
13
13
|
//#region src/adapters/standalone.ts
|
|
14
|
+
var import_objectSpread2 = require_getErrorShape.__toESM(require_getErrorShape.require_objectSpread2(), 1);
|
|
14
15
|
function createHandler(opts) {
|
|
15
|
-
|
|
16
|
+
var _opts$basePath;
|
|
17
|
+
const basePath = (_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/";
|
|
16
18
|
const sliceLength = basePath.length;
|
|
17
19
|
return (req, res) => {
|
|
18
20
|
let path = "";
|
|
19
21
|
require_utils.run(async () => {
|
|
20
22
|
const url = require_node_http.createURL(req);
|
|
21
23
|
path = url.pathname.slice(sliceLength);
|
|
22
|
-
await require_node_http.nodeHTTPRequestHandler({
|
|
23
|
-
...opts,
|
|
24
|
+
await require_node_http.nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
24
25
|
req,
|
|
25
26
|
res,
|
|
26
27
|
path
|
|
27
|
-
});
|
|
28
|
-
}).catch(require_node_http.internal_exceptionHandler({
|
|
28
|
+
}));
|
|
29
|
+
}).catch(require_node_http.internal_exceptionHandler((0, import_objectSpread2.default)({
|
|
29
30
|
req,
|
|
30
31
|
res,
|
|
31
|
-
path
|
|
32
|
-
|
|
33
|
-
}));
|
|
32
|
+
path
|
|
33
|
+
}, opts)));
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import
|
|
5
|
-
import "../
|
|
1
|
+
import { __toESM, require_objectSpread2 } from "../getErrorShape-Uhlrl4Bk.mjs";
|
|
2
|
+
import "../tracked-gU3ttYjg.mjs";
|
|
3
|
+
import { run } from "../utils-DdbbrDku.mjs";
|
|
4
|
+
import "../parseTRPCMessage-ByIHyFRz.mjs";
|
|
5
|
+
import "../resolveResponse-CzlbRpCI.mjs";
|
|
6
6
|
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
7
|
import "../unstable-core-do-not-import-D89CaGtL.mjs";
|
|
8
|
-
import "../observable-
|
|
9
|
-
import "../initTRPC-
|
|
10
|
-
import { createURL, internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-
|
|
8
|
+
import "../observable-UMO3vUa_.mjs";
|
|
9
|
+
import "../initTRPC-IT_6ZYJd.mjs";
|
|
10
|
+
import { createURL, internal_exceptionHandler, nodeHTTPRequestHandler } from "../node-http-Du8akt-R.mjs";
|
|
11
11
|
import http from "http";
|
|
12
12
|
|
|
13
13
|
//#region src/adapters/standalone.ts
|
|
14
|
+
var import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
14
15
|
function createHandler(opts) {
|
|
15
|
-
|
|
16
|
+
var _opts$basePath;
|
|
17
|
+
const basePath = (_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/";
|
|
16
18
|
const sliceLength = basePath.length;
|
|
17
19
|
return (req, res) => {
|
|
18
20
|
let path = "";
|
|
19
21
|
run(async () => {
|
|
20
22
|
const url = createURL(req);
|
|
21
23
|
path = url.pathname.slice(sliceLength);
|
|
22
|
-
await nodeHTTPRequestHandler({
|
|
23
|
-
...opts,
|
|
24
|
+
await nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
24
25
|
req,
|
|
25
26
|
res,
|
|
26
27
|
path
|
|
27
|
-
});
|
|
28
|
-
}).catch(internal_exceptionHandler({
|
|
28
|
+
}));
|
|
29
|
+
}).catch(internal_exceptionHandler((0, import_objectSpread2.default)({
|
|
29
30
|
req,
|
|
30
31
|
res,
|
|
31
|
-
path
|
|
32
|
-
|
|
33
|
-
}));
|
|
32
|
+
path
|
|
33
|
+
}, opts)));
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.mjs","names":["opts: StandaloneHandlerOptions<TRouter, TRequest, TResponse>","opts: CreateHTTPHandlerOptions<TRouter>","opts: CreateHTTP2HandlerOptions<AnyRouter>"],"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":"
|
|
1
|
+
{"version":3,"file":"standalone.mjs","names":["opts: StandaloneHandlerOptions<TRouter, TRequest, TResponse>","opts: CreateHTTPHandlerOptions<TRouter>","opts: CreateHTTP2HandlerOptions<AnyRouter>"],"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,cAKPA,MACyC;;CACzC,MAAM,6BAAW,KAAK,mEAAY;CAClC,MAAM,cAAc,SAAS;AAE7B,QAAO,CAAC,KAAK,QAAQ;EACnB,IAAI,OAAO;AAEX,MAAI,YAAY;GACd,MAAM,MAAM,UAAU,IAAI;AAG1B,UAAO,IAAI,SAAS,MAAM,YAAY;AAEtC,SAAM,+FACA;IACJ;IACA;IACA;MACA;EACH,EAAC,CAAC,MACD;GACE;GACA;GACA;KACG,MACH,CACH;CACF;AACF;;;;AAKD,SAAgB,kBACdC,MACsB;AACtB,QAAO,cAAc,KAAK;AAC3B;AAED,SAAgB,iBACdA,MACA;AACA,QAAO,KAAK,aAAa,kBAAkB,KAAK,CAAC;AAClD;AAeD,SAAgB,mBAAmBC,MAA4C;AAC7E,QAAO,cAAc,KAAK;AAC3B"}
|
package/dist/adapters/ws.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
require('../
|
|
2
|
-
require('../
|
|
3
|
-
require('../
|
|
4
|
-
require('../
|
|
5
|
-
require('../
|
|
1
|
+
require('../getErrorShape-DKiEF6Zc.cjs');
|
|
2
|
+
require('../tracked-HoF8L_mq.cjs');
|
|
3
|
+
require('../utils-BhNVZA-c.cjs');
|
|
4
|
+
require('../parseTRPCMessage-snNQop7N.cjs');
|
|
5
|
+
require('../resolveResponse-CVGbakBm.cjs');
|
|
6
6
|
require('../contentTypeParsers-iAFF_pJG.cjs');
|
|
7
7
|
require('../unstable-core-do-not-import-DFQys1IC.cjs');
|
|
8
|
-
require('../observable-
|
|
9
|
-
require('../initTRPC-
|
|
8
|
+
require('../observable-B1Nk6r1H.cjs');
|
|
9
|
+
require('../initTRPC-IT4M4lu3.cjs');
|
|
10
10
|
require('../http-DXy3XyhL.cjs');
|
|
11
|
-
require('../node-http-
|
|
12
|
-
require('../observable-
|
|
13
|
-
const require_ws = require('../ws-
|
|
11
|
+
require('../node-http-kIQEhZUH.cjs');
|
|
12
|
+
require('../observable-BVzLuBs6.cjs');
|
|
13
|
+
const require_ws = require('../ws-BhrWsMpl.cjs');
|
|
14
14
|
|
|
15
15
|
exports.applyWSSHandler = require_ws.applyWSSHandler;
|
|
16
16
|
exports.getWSConnectionHandler = require_ws.getWSConnectionHandler;
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
import "../
|
|
1
|
+
import "../getErrorShape-Uhlrl4Bk.mjs";
|
|
2
|
+
import "../tracked-gU3ttYjg.mjs";
|
|
3
|
+
import "../utils-DdbbrDku.mjs";
|
|
4
|
+
import "../parseTRPCMessage-ByIHyFRz.mjs";
|
|
5
|
+
import "../resolveResponse-CzlbRpCI.mjs";
|
|
6
6
|
import "../contentTypeParsers-SN4WL9ze.mjs";
|
|
7
7
|
import "../unstable-core-do-not-import-D89CaGtL.mjs";
|
|
8
|
-
import "../observable-
|
|
9
|
-
import "../initTRPC-
|
|
8
|
+
import "../observable-UMO3vUa_.mjs";
|
|
9
|
+
import "../initTRPC-IT_6ZYJd.mjs";
|
|
10
10
|
import "../http-CWyjOa1l.mjs";
|
|
11
|
-
import "../node-http-
|
|
12
|
-
import "../observable-
|
|
13
|
-
import { applyWSSHandler, getWSConnectionHandler, handleKeepAlive } from "../ws-
|
|
11
|
+
import "../node-http-Du8akt-R.mjs";
|
|
12
|
+
import "../observable-CUiPknO-.mjs";
|
|
13
|
+
import { applyWSSHandler, getWSConnectionHandler, handleKeepAlive } from "../ws-Bn5rkP_I.mjs";
|
|
14
14
|
|
|
15
15
|
export { applyWSSHandler, getWSConnectionHandler, handleKeepAlive };
|