@trpc/server 10.0.0-alpha.16 → 10.0.0-alpha.19

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.
Files changed (90) hide show
  1. package/adapters/express/dist/trpc-server-adapters-express.cjs.d.ts +1 -11
  2. package/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +23 -0
  3. package/adapters/express/dist/trpc-server-adapters-express.cjs.js +6 -15
  4. package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +23 -0
  5. package/adapters/express/dist/trpc-server-adapters-express.esm.js +19 -0
  6. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.d.ts +1 -11
  7. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.dev.js +102 -0
  8. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.js +6 -15
  9. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.prod.js +102 -0
  10. package/adapters/fastify/dist/trpc-server-adapters-fastify.esm.js +97 -0
  11. package/adapters/next/dist/trpc-server-adapters-next.cjs.d.ts +1 -11
  12. package/adapters/next/dist/trpc-server-adapters-next.cjs.dev.js +56 -0
  13. package/adapters/next/dist/trpc-server-adapters-next.cjs.js +6 -15
  14. package/adapters/next/dist/trpc-server-adapters-next.cjs.prod.js +56 -0
  15. package/adapters/next/dist/trpc-server-adapters-next.esm.js +52 -0
  16. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.d.ts +1 -11
  17. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.dev.js +13 -0
  18. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.js +6 -15
  19. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.prod.js +13 -0
  20. package/adapters/node-http/dist/trpc-server-adapters-node-http.esm.js +5 -0
  21. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.d.ts +1 -11
  22. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js +46 -0
  23. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.js +6 -15
  24. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js +46 -0
  25. package/adapters/standalone/dist/trpc-server-adapters-standalone.esm.js +36 -0
  26. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.d.ts +1 -11
  27. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +347 -0
  28. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.js +6 -15
  29. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +347 -0
  30. package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +343 -0
  31. package/dist/TRPCError.d.ts +0 -8
  32. package/dist/TRPCError.d.ts.map +1 -1
  33. package/dist/adapters/express.js +3 -3
  34. package/dist/adapters/express.mjs +3 -3
  35. package/dist/adapters/fastify/index.js +3 -3
  36. package/dist/adapters/fastify/index.mjs +3 -3
  37. package/dist/adapters/next.js +3 -3
  38. package/dist/adapters/next.mjs +3 -3
  39. package/dist/adapters/node-http/index.js +3 -3
  40. package/dist/adapters/node-http/index.mjs +3 -3
  41. package/dist/adapters/standalone.js +3 -3
  42. package/dist/adapters/standalone.mjs +3 -3
  43. package/dist/adapters/ws.js +2 -2
  44. package/dist/adapters/ws.mjs +2 -2
  45. package/dist/index.d.ts +1 -3
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +4 -42
  48. package/dist/index.mjs +6 -40
  49. package/dist/{nodeHTTPRequestHandler-17b64c0e.js → nodeHTTPRequestHandler-e02d6e5d.js} +2 -2
  50. package/dist/{nodeHTTPRequestHandler-17a5e0dd.mjs → nodeHTTPRequestHandler-f9b7cd2d.mjs} +2 -2
  51. package/dist/{resolveHTTPResponse-9604d47d.mjs → resolveHTTPResponse-ca8bc869.mjs} +1 -1
  52. package/dist/{resolveHTTPResponse-087ce86a.js → resolveHTTPResponse-d4da195d.js} +1 -1
  53. package/dist/router.d.ts +0 -7
  54. package/dist/router.d.ts.map +1 -1
  55. package/dist/{subscription-e1d42e69.mjs → subscription-7ec5884e.mjs} +1 -1
  56. package/dist/{subscription-5b7e1eba.js → subscription-f36af4f8.js} +1 -1
  57. package/dist/{transformTRPCResponse-bd24f548.js → transformTRPCResponse-eeeb5300.js} +3 -7
  58. package/dist/{transformTRPCResponse-76e0c91e.mjs → transformTRPCResponse-f9337285.mjs} +3 -7
  59. package/dist/types.d.ts +0 -8
  60. package/dist/types.d.ts.map +1 -1
  61. package/package.json +3 -8
  62. package/rpc/dist/trpc-server-rpc.cjs.d.ts +1 -11
  63. package/rpc/dist/trpc-server-rpc.cjs.dev.js +10 -0
  64. package/rpc/dist/trpc-server-rpc.cjs.js +6 -15
  65. package/rpc/dist/trpc-server-rpc.cjs.prod.js +10 -0
  66. package/rpc/dist/trpc-server-rpc.esm.js +1 -0
  67. package/src/TRPCError.ts +2 -10
  68. package/src/index.ts +1 -5
  69. package/src/router.ts +0 -25
  70. package/src/types.ts +0 -9
  71. package/ws/dist/trpc-server-ws.cjs.d.ts +1 -11
  72. package/ws/dist/trpc-server-ws.cjs.dev.js +15 -0
  73. package/ws/dist/trpc-server-ws.cjs.js +6 -15
  74. package/ws/dist/trpc-server-ws.cjs.prod.js +15 -0
  75. package/ws/dist/trpc-server-ws.esm.js +11 -0
  76. package/dist/deprecated/LegacyRouter.d.ts +0 -3
  77. package/dist/deprecated/LegacyRouter.d.ts.map +0 -1
  78. package/dist/deprecated/createHttpServer.d.ts +0 -19
  79. package/dist/deprecated/createHttpServer.d.ts.map +0 -1
  80. package/dist/deprecated/requestHandler.d.ts +0 -15
  81. package/dist/deprecated/requestHandler.d.ts.map +0 -1
  82. package/dist/ws/index.d.ts +0 -7
  83. package/dist/ws/index.d.ts.map +0 -1
  84. package/dist/ws/index.js +0 -15
  85. package/dist/ws/index.mjs +0 -11
  86. package/dist/ws/index.ts.js +0 -1
  87. package/src/deprecated/LegacyRouter.ts +0 -3
  88. package/src/deprecated/createHttpServer.ts +0 -29
  89. package/src/deprecated/requestHandler.ts +0 -26
  90. package/src/ws/index.ts +0 -8
@@ -1,11 +1 @@
1
- // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
- // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
-
4
- // curious why you need to?
5
- // this file exists so that you can import from the entrypoint normally
6
- // except that it points to your source file and you don't need to run build constantly
7
- // which means we need to re-export all of the modules from your source file
8
- // and since export * doesn't include default exports, we need to read your source file
9
- // to check for a default export and re-export it if it exists
10
- // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
- export * from "../../../src/adapters/express";
1
+ export * from "../../../dist/declarations/src/adapters/express";
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodeHTTPRequestHandler = require('../../../dist/nodeHTTPRequestHandler-2cc444d8.cjs.dev.js');
6
+ require('url');
7
+ require('../../../dist/resolveHTTPResponse-3867844c.cjs.dev.js');
8
+ require('../../../dist/transformTRPCResponse-8248515e.cjs.dev.js');
9
+ require('../../../dist/codes-33cef953.cjs.dev.js');
10
+
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ function createExpressMiddleware(opts) {
13
+ return (req, res) => {
14
+ const endpoint = req.path.slice(1);
15
+ nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
16
+ req,
17
+ res,
18
+ path: endpoint
19
+ });
20
+ };
21
+ }
22
+
23
+ exports.createExpressMiddleware = createExpressMiddleware;
@@ -1,16 +1,7 @@
1
- "use strict";
2
- // this file might look strange and you might be wondering what it's for
3
- // it's lets you import your source files by importing this entrypoint
4
- // as you would import it if it was built with preconstruct build
5
- // this file is slightly different to some others though
6
- // it has a require hook which compiles your code with Babel
7
- // this means that you don't have to set up @babel/register or anything like that
8
- // but you can still require this module and it'll be compiled
1
+ 'use strict';
9
2
 
10
- // this bit of code imports the require hook and registers it
11
- let unregister = require("../../../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
-
13
- // this re-exports the source file
14
- module.exports = require("../../../src/adapters/express.ts");
15
-
16
- unregister();
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./trpc-server-adapters-express.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./trpc-server-adapters-express.cjs.dev.js");
7
+ }
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodeHTTPRequestHandler = require('../../../dist/nodeHTTPRequestHandler-8ddacc19.cjs.prod.js');
6
+ require('url');
7
+ require('../../../dist/resolveHTTPResponse-562c3d62.cjs.prod.js');
8
+ require('../../../dist/transformTRPCResponse-dcbf66c5.cjs.prod.js');
9
+ require('../../../dist/codes-e0df67c4.cjs.prod.js');
10
+
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ function createExpressMiddleware(opts) {
13
+ return (req, res) => {
14
+ const endpoint = req.path.slice(1);
15
+ nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
16
+ req,
17
+ res,
18
+ path: endpoint
19
+ });
20
+ };
21
+ }
22
+
23
+ exports.createExpressMiddleware = createExpressMiddleware;
@@ -0,0 +1,19 @@
1
+ import { n as nodeHTTPRequestHandler } from '../../../dist/nodeHTTPRequestHandler-d00c1126.esm.js';
2
+ import 'url';
3
+ import '../../../dist/resolveHTTPResponse-85f3f5df.esm.js';
4
+ import '../../../dist/transformTRPCResponse-f73dc4a2.esm.js';
5
+ import '../../../dist/codes-fe07bf82.esm.js';
6
+
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ function createExpressMiddleware(opts) {
9
+ return (req, res) => {
10
+ const endpoint = req.path.slice(1);
11
+ nodeHTTPRequestHandler({ ...opts,
12
+ req,
13
+ res,
14
+ path: endpoint
15
+ });
16
+ };
17
+ }
18
+
19
+ export { createExpressMiddleware };
@@ -1,11 +1 @@
1
- // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
- // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
-
4
- // curious why you need to?
5
- // this file exists so that you can import from the entrypoint normally
6
- // except that it points to your source file and you don't need to run build constantly
7
- // which means we need to re-export all of the modules from your source file
8
- // and since export * doesn't include default exports, we need to read your source file
9
- // to check for a default export and re-export it if it exists
10
- // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
- export * from "../../../src/adapters/fastify/index";
1
+ export * from "../../../dist/declarations/src/adapters/fastify/index";
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var url = require('url');
6
+ var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-3867844c.cjs.dev.js');
7
+ var adapters_ws_dist_trpcServerAdaptersWs = require('../../ws/dist/trpc-server-adapters-ws.cjs.dev.js');
8
+ require('../../../dist/transformTRPCResponse-8248515e.cjs.dev.js');
9
+ require('../../../dist/codes-33cef953.cjs.dev.js');
10
+ require('../../../dist/subscription-b8831081.cjs.dev.js');
11
+ require('events');
12
+
13
+ resolveHTTPResponse.assertNotBrowser();
14
+ async function fastifyRequestHandler(opts) {
15
+ var _opts$req$body;
16
+
17
+ const createContext = async function _createContext() {
18
+ var _opts$createContext;
19
+
20
+ return (_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, opts);
21
+ };
22
+
23
+ const query = opts.req.query ? new url.URLSearchParams(opts.req.query) : new url.URLSearchParams(opts.req.url.split('?')[1]);
24
+ const req = {
25
+ query,
26
+ method: opts.req.method,
27
+ headers: opts.req.headers,
28
+ body: (_opts$req$body = opts.req.body) !== null && _opts$req$body !== void 0 ? _opts$req$body : 'null'
29
+ };
30
+ const result = await resolveHTTPResponse.resolveHTTPResponse({
31
+ req,
32
+ createContext,
33
+ path: opts.path,
34
+ router: opts.router,
35
+ batching: opts.batching,
36
+ responseMeta: opts.responseMeta,
37
+
38
+ onError(o) {
39
+ var _opts$onError;
40
+
41
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
42
+ req: opts.req
43
+ });
44
+ }
45
+
46
+ });
47
+ const {
48
+ res
49
+ } = opts;
50
+
51
+ if ('status' in result && (!res.statusCode || res.statusCode === 200)) {
52
+ res.statusCode = result.status;
53
+ }
54
+
55
+ for (const [key, value] of Object.entries((_result$headers = result.headers) !== null && _result$headers !== void 0 ? _result$headers : {})) {
56
+ var _result$headers;
57
+
58
+ if (typeof value === 'undefined') {
59
+ continue;
60
+ }
61
+
62
+ res.header(key, value);
63
+ }
64
+
65
+ res.send(result.body);
66
+ }
67
+
68
+ /// <reference types="fastify-websocket" />
69
+ function fastifyTRPCPlugin(fastify, opts, done) {
70
+ var _opts$prefix;
71
+
72
+ fastify.addContentTypeParser('application/json', {
73
+ parseAs: 'string'
74
+ }, function (_, body, _done) {
75
+ _done(null, body);
76
+ });
77
+ fastify.all(`${(_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''}/:path`, (req, res) => {
78
+ const path = req.params.path;
79
+ fastifyRequestHandler({ ...opts.trpcOptions,
80
+ req,
81
+ res,
82
+ path
83
+ });
84
+ });
85
+
86
+ if (opts.useWSS) {
87
+ var _opts$prefix2;
88
+
89
+ adapters_ws_dist_trpcServerAdaptersWs.applyWSSHandler({ ...opts.trpcOptions,
90
+ wss: fastify.websocketServer
91
+ }); // eslint-disable-next-line @typescript-eslint/no-empty-function
92
+
93
+ fastify.get((_opts$prefix2 = opts.prefix) !== null && _opts$prefix2 !== void 0 ? _opts$prefix2 : '/', {
94
+ websocket: true
95
+ }, () => {});
96
+ }
97
+
98
+ done();
99
+ }
100
+
101
+ exports.fastifyRequestHandler = fastifyRequestHandler;
102
+ exports.fastifyTRPCPlugin = fastifyTRPCPlugin;
@@ -1,16 +1,7 @@
1
- "use strict";
2
- // this file might look strange and you might be wondering what it's for
3
- // it's lets you import your source files by importing this entrypoint
4
- // as you would import it if it was built with preconstruct build
5
- // this file is slightly different to some others though
6
- // it has a require hook which compiles your code with Babel
7
- // this means that you don't have to set up @babel/register or anything like that
8
- // but you can still require this module and it'll be compiled
1
+ 'use strict';
9
2
 
10
- // this bit of code imports the require hook and registers it
11
- let unregister = require("../../../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
-
13
- // this re-exports the source file
14
- module.exports = require("../../../src/adapters/fastify/index.ts");
15
-
16
- unregister();
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./trpc-server-adapters-fastify.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./trpc-server-adapters-fastify.cjs.dev.js");
7
+ }
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var url = require('url');
6
+ var resolveHTTPResponse = require('../../../dist/resolveHTTPResponse-562c3d62.cjs.prod.js');
7
+ var adapters_ws_dist_trpcServerAdaptersWs = require('../../ws/dist/trpc-server-adapters-ws.cjs.prod.js');
8
+ require('../../../dist/transformTRPCResponse-dcbf66c5.cjs.prod.js');
9
+ require('../../../dist/codes-e0df67c4.cjs.prod.js');
10
+ require('../../../dist/subscription-c2e0bfbc.cjs.prod.js');
11
+ require('events');
12
+
13
+ resolveHTTPResponse.assertNotBrowser();
14
+ async function fastifyRequestHandler(opts) {
15
+ var _opts$req$body;
16
+
17
+ const createContext = async function _createContext() {
18
+ var _opts$createContext;
19
+
20
+ return (_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, opts);
21
+ };
22
+
23
+ const query = opts.req.query ? new url.URLSearchParams(opts.req.query) : new url.URLSearchParams(opts.req.url.split('?')[1]);
24
+ const req = {
25
+ query,
26
+ method: opts.req.method,
27
+ headers: opts.req.headers,
28
+ body: (_opts$req$body = opts.req.body) !== null && _opts$req$body !== void 0 ? _opts$req$body : 'null'
29
+ };
30
+ const result = await resolveHTTPResponse.resolveHTTPResponse({
31
+ req,
32
+ createContext,
33
+ path: opts.path,
34
+ router: opts.router,
35
+ batching: opts.batching,
36
+ responseMeta: opts.responseMeta,
37
+
38
+ onError(o) {
39
+ var _opts$onError;
40
+
41
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
42
+ req: opts.req
43
+ });
44
+ }
45
+
46
+ });
47
+ const {
48
+ res
49
+ } = opts;
50
+
51
+ if ('status' in result && (!res.statusCode || res.statusCode === 200)) {
52
+ res.statusCode = result.status;
53
+ }
54
+
55
+ for (const [key, value] of Object.entries((_result$headers = result.headers) !== null && _result$headers !== void 0 ? _result$headers : {})) {
56
+ var _result$headers;
57
+
58
+ if (typeof value === 'undefined') {
59
+ continue;
60
+ }
61
+
62
+ res.header(key, value);
63
+ }
64
+
65
+ res.send(result.body);
66
+ }
67
+
68
+ /// <reference types="fastify-websocket" />
69
+ function fastifyTRPCPlugin(fastify, opts, done) {
70
+ var _opts$prefix;
71
+
72
+ fastify.addContentTypeParser('application/json', {
73
+ parseAs: 'string'
74
+ }, function (_, body, _done) {
75
+ _done(null, body);
76
+ });
77
+ fastify.all(`${(_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''}/:path`, (req, res) => {
78
+ const path = req.params.path;
79
+ fastifyRequestHandler({ ...opts.trpcOptions,
80
+ req,
81
+ res,
82
+ path
83
+ });
84
+ });
85
+
86
+ if (opts.useWSS) {
87
+ var _opts$prefix2;
88
+
89
+ adapters_ws_dist_trpcServerAdaptersWs.applyWSSHandler({ ...opts.trpcOptions,
90
+ wss: fastify.websocketServer
91
+ }); // eslint-disable-next-line @typescript-eslint/no-empty-function
92
+
93
+ fastify.get((_opts$prefix2 = opts.prefix) !== null && _opts$prefix2 !== void 0 ? _opts$prefix2 : '/', {
94
+ websocket: true
95
+ }, () => {});
96
+ }
97
+
98
+ done();
99
+ }
100
+
101
+ exports.fastifyRequestHandler = fastifyRequestHandler;
102
+ exports.fastifyTRPCPlugin = fastifyTRPCPlugin;
@@ -0,0 +1,97 @@
1
+ import { URLSearchParams } from 'url';
2
+ import { a as assertNotBrowser, r as resolveHTTPResponse } from '../../../dist/resolveHTTPResponse-85f3f5df.esm.js';
3
+ import { applyWSSHandler } from '../../ws/dist/trpc-server-adapters-ws.esm.js';
4
+ import '../../../dist/transformTRPCResponse-f73dc4a2.esm.js';
5
+ import '../../../dist/codes-fe07bf82.esm.js';
6
+ import '../../../dist/subscription-fbda2888.esm.js';
7
+ import 'events';
8
+
9
+ assertNotBrowser();
10
+ async function fastifyRequestHandler(opts) {
11
+ var _opts$req$body;
12
+
13
+ const createContext = async function _createContext() {
14
+ var _opts$createContext;
15
+
16
+ return (_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, opts);
17
+ };
18
+
19
+ const query = opts.req.query ? new URLSearchParams(opts.req.query) : new URLSearchParams(opts.req.url.split('?')[1]);
20
+ const req = {
21
+ query,
22
+ method: opts.req.method,
23
+ headers: opts.req.headers,
24
+ body: (_opts$req$body = opts.req.body) !== null && _opts$req$body !== void 0 ? _opts$req$body : 'null'
25
+ };
26
+ const result = await resolveHTTPResponse({
27
+ req,
28
+ createContext,
29
+ path: opts.path,
30
+ router: opts.router,
31
+ batching: opts.batching,
32
+ responseMeta: opts.responseMeta,
33
+
34
+ onError(o) {
35
+ var _opts$onError;
36
+
37
+ opts === null || opts === void 0 ? void 0 : (_opts$onError = opts.onError) === null || _opts$onError === void 0 ? void 0 : _opts$onError.call(opts, { ...o,
38
+ req: opts.req
39
+ });
40
+ }
41
+
42
+ });
43
+ const {
44
+ res
45
+ } = opts;
46
+
47
+ if ('status' in result && (!res.statusCode || res.statusCode === 200)) {
48
+ res.statusCode = result.status;
49
+ }
50
+
51
+ for (const [key, value] of Object.entries((_result$headers = result.headers) !== null && _result$headers !== void 0 ? _result$headers : {})) {
52
+ var _result$headers;
53
+
54
+ if (typeof value === 'undefined') {
55
+ continue;
56
+ }
57
+
58
+ res.header(key, value);
59
+ }
60
+
61
+ res.send(result.body);
62
+ }
63
+
64
+ /// <reference types="fastify-websocket" />
65
+ function fastifyTRPCPlugin(fastify, opts, done) {
66
+ var _opts$prefix;
67
+
68
+ fastify.addContentTypeParser('application/json', {
69
+ parseAs: 'string'
70
+ }, function (_, body, _done) {
71
+ _done(null, body);
72
+ });
73
+ fastify.all(`${(_opts$prefix = opts.prefix) !== null && _opts$prefix !== void 0 ? _opts$prefix : ''}/:path`, (req, res) => {
74
+ const path = req.params.path;
75
+ fastifyRequestHandler({ ...opts.trpcOptions,
76
+ req,
77
+ res,
78
+ path
79
+ });
80
+ });
81
+
82
+ if (opts.useWSS) {
83
+ var _opts$prefix2;
84
+
85
+ applyWSSHandler({ ...opts.trpcOptions,
86
+ wss: fastify.websocketServer
87
+ }); // eslint-disable-next-line @typescript-eslint/no-empty-function
88
+
89
+ fastify.get((_opts$prefix2 = opts.prefix) !== null && _opts$prefix2 !== void 0 ? _opts$prefix2 : '/', {
90
+ websocket: true
91
+ }, () => {});
92
+ }
93
+
94
+ done();
95
+ }
96
+
97
+ export { fastifyRequestHandler, fastifyTRPCPlugin };
@@ -1,11 +1 @@
1
- // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
- // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
-
4
- // curious why you need to?
5
- // this file exists so that you can import from the entrypoint normally
6
- // except that it points to your source file and you don't need to run build constantly
7
- // which means we need to re-export all of the modules from your source file
8
- // and since export * doesn't include default exports, we need to read your source file
9
- // to check for a default export and re-export it if it exists
10
- // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
- export * from "../../../src/adapters/next";
1
+ export * from "../../../dist/declarations/src/adapters/next";
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var transformTRPCResponse = require('../../../dist/transformTRPCResponse-8248515e.cjs.dev.js');
6
+ var nodeHTTPRequestHandler = require('../../../dist/nodeHTTPRequestHandler-2cc444d8.cjs.dev.js');
7
+ require('url');
8
+ require('../../../dist/resolveHTTPResponse-3867844c.cjs.dev.js');
9
+ require('../../../dist/codes-33cef953.cjs.dev.js');
10
+
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ function createNextApiHandler(opts) {
13
+ return async (req, res) => {
14
+ function getPath() {
15
+ if (typeof req.query.trpc === 'string') {
16
+ return req.query.trpc;
17
+ }
18
+
19
+ if (Array.isArray(req.query.trpc)) {
20
+ return req.query.trpc.join('/');
21
+ }
22
+
23
+ return null;
24
+ }
25
+
26
+ const path = getPath();
27
+
28
+ if (path === null) {
29
+ const error = opts.router.getErrorShape({
30
+ error: new transformTRPCResponse.TRPCError({
31
+ message: 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
32
+ code: 'INTERNAL_SERVER_ERROR'
33
+ }),
34
+ type: 'unknown',
35
+ ctx: undefined,
36
+ path: undefined,
37
+ input: undefined
38
+ });
39
+ const json = {
40
+ id: -1,
41
+ error
42
+ };
43
+ res.statusCode = 500;
44
+ res.json(json);
45
+ return;
46
+ }
47
+
48
+ await nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
49
+ req,
50
+ res,
51
+ path
52
+ });
53
+ };
54
+ }
55
+
56
+ exports.createNextApiHandler = createNextApiHandler;
@@ -1,16 +1,7 @@
1
- "use strict";
2
- // this file might look strange and you might be wondering what it's for
3
- // it's lets you import your source files by importing this entrypoint
4
- // as you would import it if it was built with preconstruct build
5
- // this file is slightly different to some others though
6
- // it has a require hook which compiles your code with Babel
7
- // this means that you don't have to set up @babel/register or anything like that
8
- // but you can still require this module and it'll be compiled
1
+ 'use strict';
9
2
 
10
- // this bit of code imports the require hook and registers it
11
- let unregister = require("../../../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../../../..", "../../..");
12
-
13
- // this re-exports the source file
14
- module.exports = require("../../../src/adapters/next.ts");
15
-
16
- unregister();
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./trpc-server-adapters-next.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./trpc-server-adapters-next.cjs.dev.js");
7
+ }
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var transformTRPCResponse = require('../../../dist/transformTRPCResponse-dcbf66c5.cjs.prod.js');
6
+ var nodeHTTPRequestHandler = require('../../../dist/nodeHTTPRequestHandler-8ddacc19.cjs.prod.js');
7
+ require('url');
8
+ require('../../../dist/resolveHTTPResponse-562c3d62.cjs.prod.js');
9
+ require('../../../dist/codes-e0df67c4.cjs.prod.js');
10
+
11
+ /* eslint-disable @typescript-eslint/no-explicit-any */
12
+ function createNextApiHandler(opts) {
13
+ return async (req, res) => {
14
+ function getPath() {
15
+ if (typeof req.query.trpc === 'string') {
16
+ return req.query.trpc;
17
+ }
18
+
19
+ if (Array.isArray(req.query.trpc)) {
20
+ return req.query.trpc.join('/');
21
+ }
22
+
23
+ return null;
24
+ }
25
+
26
+ const path = getPath();
27
+
28
+ if (path === null) {
29
+ const error = opts.router.getErrorShape({
30
+ error: new transformTRPCResponse.TRPCError({
31
+ message: 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
32
+ code: 'INTERNAL_SERVER_ERROR'
33
+ }),
34
+ type: 'unknown',
35
+ ctx: undefined,
36
+ path: undefined,
37
+ input: undefined
38
+ });
39
+ const json = {
40
+ id: -1,
41
+ error
42
+ };
43
+ res.statusCode = 500;
44
+ res.json(json);
45
+ return;
46
+ }
47
+
48
+ await nodeHTTPRequestHandler.nodeHTTPRequestHandler({ ...opts,
49
+ req,
50
+ res,
51
+ path
52
+ });
53
+ };
54
+ }
55
+
56
+ exports.createNextApiHandler = createNextApiHandler;
@@ -0,0 +1,52 @@
1
+ import { T as TRPCError } from '../../../dist/transformTRPCResponse-f73dc4a2.esm.js';
2
+ import { n as nodeHTTPRequestHandler } from '../../../dist/nodeHTTPRequestHandler-d00c1126.esm.js';
3
+ import 'url';
4
+ import '../../../dist/resolveHTTPResponse-85f3f5df.esm.js';
5
+ import '../../../dist/codes-fe07bf82.esm.js';
6
+
7
+ /* eslint-disable @typescript-eslint/no-explicit-any */
8
+ function createNextApiHandler(opts) {
9
+ return async (req, res) => {
10
+ function getPath() {
11
+ if (typeof req.query.trpc === 'string') {
12
+ return req.query.trpc;
13
+ }
14
+
15
+ if (Array.isArray(req.query.trpc)) {
16
+ return req.query.trpc.join('/');
17
+ }
18
+
19
+ return null;
20
+ }
21
+
22
+ const path = getPath();
23
+
24
+ if (path === null) {
25
+ const error = opts.router.getErrorShape({
26
+ error: new TRPCError({
27
+ message: 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?',
28
+ code: 'INTERNAL_SERVER_ERROR'
29
+ }),
30
+ type: 'unknown',
31
+ ctx: undefined,
32
+ path: undefined,
33
+ input: undefined
34
+ });
35
+ const json = {
36
+ id: -1,
37
+ error
38
+ };
39
+ res.statusCode = 500;
40
+ res.json(json);
41
+ return;
42
+ }
43
+
44
+ await nodeHTTPRequestHandler({ ...opts,
45
+ req,
46
+ res,
47
+ path
48
+ });
49
+ };
50
+ }
51
+
52
+ export { createNextApiHandler };
@@ -1,11 +1 @@
1
- // are you seeing an error that a default export doesn't exist but your source file has a default export?
2
- // you should run `yarn` or `yarn preconstruct dev` if preconstruct dev isn't in your postinstall hook
3
-
4
- // curious why you need to?
5
- // this file exists so that you can import from the entrypoint normally
6
- // except that it points to your source file and you don't need to run build constantly
7
- // which means we need to re-export all of the modules from your source file
8
- // and since export * doesn't include default exports, we need to read your source file
9
- // to check for a default export and re-export it if it exists
10
- // it's not ideal, but it works pretty well ¯\_(ツ)_/¯
11
- export * from "../../../src/adapters/node-http/index";
1
+ export * from "../../../dist/declarations/src/adapters/node-http/index";