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

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 (45) hide show
  1. package/adapters/express/dist/trpc-server-adapters-express.cjs.d.ts +11 -1
  2. package/adapters/express/dist/trpc-server-adapters-express.cjs.js +15 -6
  3. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.d.ts +11 -1
  4. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.js +15 -6
  5. package/adapters/next/dist/trpc-server-adapters-next.cjs.d.ts +11 -1
  6. package/adapters/next/dist/trpc-server-adapters-next.cjs.js +15 -6
  7. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.d.ts +11 -1
  8. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.js +15 -6
  9. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.d.ts +11 -1
  10. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.js +15 -6
  11. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.d.ts +11 -1
  12. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.js +15 -6
  13. package/dist/adapters/ws.d.ts.map +1 -1
  14. package/dist/adapters/ws.js +2 -1
  15. package/dist/adapters/ws.mjs +2 -1
  16. package/package.json +2 -2
  17. package/rpc/dist/trpc-server-rpc.cjs.d.ts +11 -1
  18. package/rpc/dist/trpc-server-rpc.cjs.js +15 -6
  19. package/src/adapters/ws.ts +4 -1
  20. package/ws/dist/trpc-server-ws.cjs.d.ts +11 -1
  21. package/ws/dist/trpc-server-ws.cjs.js +15 -6
  22. package/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +0 -23
  23. package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +0 -23
  24. package/adapters/express/dist/trpc-server-adapters-express.esm.js +0 -19
  25. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.dev.js +0 -102
  26. package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.prod.js +0 -102
  27. package/adapters/fastify/dist/trpc-server-adapters-fastify.esm.js +0 -97
  28. package/adapters/next/dist/trpc-server-adapters-next.cjs.dev.js +0 -56
  29. package/adapters/next/dist/trpc-server-adapters-next.cjs.prod.js +0 -56
  30. package/adapters/next/dist/trpc-server-adapters-next.esm.js +0 -52
  31. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.dev.js +0 -13
  32. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.prod.js +0 -13
  33. package/adapters/node-http/dist/trpc-server-adapters-node-http.esm.js +0 -5
  34. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js +0 -46
  35. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js +0 -46
  36. package/adapters/standalone/dist/trpc-server-adapters-standalone.esm.js +0 -36
  37. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +0 -347
  38. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +0 -347
  39. package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +0 -343
  40. package/rpc/dist/trpc-server-rpc.cjs.dev.js +0 -10
  41. package/rpc/dist/trpc-server-rpc.cjs.prod.js +0 -10
  42. package/rpc/dist/trpc-server-rpc.esm.js +0 -1
  43. package/ws/dist/trpc-server-ws.cjs.dev.js +0 -15
  44. package/ws/dist/trpc-server-ws.cjs.prod.js +0 -15
  45. package/ws/dist/trpc-server-ws.esm.js +0 -11
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/express";
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,7 +1,16 @@
1
- 'use strict';
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
2
9
 
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
- }
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();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/fastify/index";
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,7 +1,16 @@
1
- 'use strict';
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
2
9
 
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
- }
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();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/next";
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,7 +1,16 @@
1
- 'use strict';
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
2
9
 
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
- }
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();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/node-http/index";
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,7 +1,16 @@
1
- 'use strict';
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
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-server-adapters-node-http.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-server-adapters-node-http.cjs.dev.js");
7
- }
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/node-http/index.ts");
15
+
16
+ unregister();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/standalone";
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/standalone";
@@ -1,7 +1,16 @@
1
- 'use strict';
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
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-server-adapters-standalone.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-server-adapters-standalone.cjs.dev.js");
7
- }
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/standalone.ts");
15
+
16
+ unregister();
@@ -1 +1,11 @@
1
- export * from "../../../dist/declarations/src/adapters/ws";
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/ws";
@@ -1,7 +1,16 @@
1
- 'use strict';
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
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-server-adapters-ws.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-server-adapters-ws.cjs.dev.js");
7
- }
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/ws.ts");
15
+
16
+ unregister();
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EAAE,SAAS,EAAqC,MAAM,WAAW,CAAC;AAUzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAiE1D;;GAEG;AACH,oBAAY,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,IAAI,CAAC,eAAe,CACrB,GAAG;IACF,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC1B,GAAG,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAEnE,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAgNjC"}
1
+ {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EAAE,SAAS,EAAqC,MAAM,WAAW,CAAC;AAUzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAiE1D;;GAEG;AACH,oBAAY,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,IAAI,CAAC,eAAe,CACrB,GAAG;IACF,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC1B,GAAG,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAEnE,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAmNjC"}
@@ -263,7 +263,8 @@ function applyWSSHandler(opts) {
263
263
  try {
264
264
  const msgJSON = JSON.parse(message.toString());
265
265
  const msgs = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
266
- msgs.map(raw => parseMessage(raw, transformer)).map(handleRequest);
266
+ const promises = msgs.map(raw => parseMessage(raw, transformer)).map(handleRequest);
267
+ await Promise.all(promises);
267
268
  } catch (cause) {
268
269
  const error = new transformTRPCResponse.TRPCError({
269
270
  code: 'PARSE_ERROR',
@@ -259,7 +259,8 @@ function applyWSSHandler(opts) {
259
259
  try {
260
260
  const msgJSON = JSON.parse(message.toString());
261
261
  const msgs = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
262
- msgs.map(raw => parseMessage(raw, transformer)).map(handleRequest);
262
+ const promises = msgs.map(raw => parseMessage(raw, transformer)).map(handleRequest);
263
+ await Promise.all(promises);
263
264
  } catch (cause) {
264
265
  const error = new TRPCError({
265
266
  code: 'PARSE_ERROR',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "10.0.0-alpha.13",
3
+ "version": "10.0.0-alpha.16",
4
4
  "description": "tRPC Server",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -105,7 +105,7 @@
105
105
  "yup": "^0.32.8",
106
106
  "zod": "^3.0.0"
107
107
  },
108
- "gitHead": "aafb25cff516b69bbb11137f2f3afa0304cc4006",
108
+ "gitHead": "08a4af55145d079964f6698130223ebe9b9bed6b",
109
109
  "dependencies": {
110
110
  "tslib": "^2.1.0"
111
111
  }
@@ -1 +1,11 @@
1
- export * from "../../dist/declarations/src/rpc/index";
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/rpc/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
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
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-server-rpc.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-server-rpc.cjs.dev.js");
7
- }
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/rpc/index.ts");
15
+
16
+ unregister();
@@ -225,7 +225,10 @@ export function applyWSSHandler<TRouter extends AnyRouter>(
225
225
  try {
226
226
  const msgJSON: unknown = JSON.parse(message.toString());
227
227
  const msgs: unknown[] = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
228
- msgs.map((raw) => parseMessage(raw, transformer)).map(handleRequest);
228
+ const promises = msgs
229
+ .map((raw) => parseMessage(raw, transformer))
230
+ .map(handleRequest);
231
+ await Promise.all(promises);
229
232
  } catch (cause) {
230
233
  const error = new TRPCError({
231
234
  code: 'PARSE_ERROR',
@@ -1 +1,11 @@
1
- export * from "../../dist/declarations/src/ws/index";
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/ws/index";
@@ -1,7 +1,16 @@
1
- 'use strict';
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
2
9
 
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./trpc-server-ws.cjs.prod.js");
5
- } else {
6
- module.exports = require("./trpc-server-ws.cjs.dev.js");
7
- }
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/ws/index.ts");
15
+
16
+ unregister();
@@ -1,23 +0,0 @@
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,23 +0,0 @@
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;
@@ -1,19 +0,0 @@
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,102 +0,0 @@
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,102 +0,0 @@
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;