@trpc/server 11.0.0-rc.608 → 11.0.0-rc.621

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 (36) hide show
  1. package/dist/@trpc/server/http.d.ts +1 -1
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/adapters/fetch/fetchRequestHandler.js +1 -2
  4. package/dist/adapters/fetch/fetchRequestHandler.mjs +1 -2
  5. package/dist/adapters/node-http/incomingMessageToRequest.d.ts +1 -0
  6. package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
  7. package/dist/adapters/node-http/incomingMessageToRequest.js +79 -40
  8. package/dist/adapters/node-http/incomingMessageToRequest.mjs +79 -41
  9. package/dist/adapters/node-http/index.js +1 -0
  10. package/dist/adapters/node-http/index.mjs +1 -1
  11. package/dist/adapters/standalone.d.ts.map +1 -1
  12. package/dist/adapters/standalone.js +2 -2
  13. package/dist/adapters/standalone.mjs +2 -2
  14. package/dist/adapters/ws.d.ts +1 -1
  15. package/dist/adapters/ws.d.ts.map +1 -1
  16. package/dist/adapters/ws.js +2 -2
  17. package/dist/adapters/ws.mjs +2 -2
  18. package/dist/bundle-analysis.json +86 -100
  19. package/dist/http.js +0 -2
  20. package/dist/http.mjs +0 -1
  21. package/dist/unstable-core-do-not-import.d.ts +0 -1
  22. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  23. package/dist/unstable-core-do-not-import.js +0 -2
  24. package/dist/unstable-core-do-not-import.mjs +0 -1
  25. package/package.json +2 -2
  26. package/src/@trpc/server/http.ts +0 -1
  27. package/src/adapters/fetch/fetchRequestHandler.ts +2 -2
  28. package/src/adapters/node-http/incomingMessageToRequest.ts +106 -41
  29. package/src/adapters/standalone.ts +7 -4
  30. package/src/adapters/ws.ts +3 -3
  31. package/src/unstable-core-do-not-import.ts +0 -1
  32. package/dist/unstable-core-do-not-import/http/toURL.d.ts +0 -2
  33. package/dist/unstable-core-do-not-import/http/toURL.d.ts.map +0 -1
  34. package/dist/unstable-core-do-not-import/http/toURL.js +0 -18
  35. package/dist/unstable-core-do-not-import/http/toURL.mjs +0 -16
  36. package/src/unstable-core-do-not-import/http/toURL.ts +0 -17
@@ -4,5 +4,5 @@ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPErrorHandler,
4
4
  * @deprecated Use `HTTPErrorHandler` instead
5
5
  */
6
6
  HTTPErrorHandler as OnErrorFunction, ResolveHTTPRequestOptionsContextFn, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from '../../unstable-core-do-not-import';
7
- export { getBatchStreamFormatter, octetInputParser, parseConnectionParamsFromUnknown, parseConnectionParamsFromString, toURL, } from '../../unstable-core-do-not-import';
7
+ export { getBatchStreamFormatter, octetInputParser, parseConnectionParamsFromUnknown, parseConnectionParamsFromString, } from '../../unstable-core-do-not-import';
8
8
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB;AAChB;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,kCAAkC,EAClC,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gCAAgC,EAChC,+BAA+B,EAC/B,KAAK,GACN,MAAM,mCAAmC,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/@trpc/server/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB;AAChB;;GAEG;AACH,gBAAgB,IAAI,eAAe,EACnC,kCAAkC,EAClC,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,mCAAmC,CAAC"}
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var resolveResponse = require('../../unstable-core-do-not-import/http/resolveResponse.js');
4
- var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
5
4
  require('../../unstable-core-do-not-import/rootConfig.js');
6
5
 
7
6
  /**
@@ -27,7 +26,7 @@ async function fetchRequestHandler(opts) {
27
26
  ...innerOpts
28
27
  });
29
28
  };
30
- const url = toURL.toURL(opts.req.url);
29
+ const url = new URL(opts.req.url);
31
30
  const pathname = trimSlashes(url.pathname);
32
31
  const endpoint = trimSlashes(opts.endpoint);
33
32
  const path = trimSlashes(pathname.slice(endpoint.length));
@@ -1,5 +1,4 @@
1
1
  import { resolveResponse } from '../../unstable-core-do-not-import/http/resolveResponse.mjs';
2
- import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
3
2
  import '../../unstable-core-do-not-import/rootConfig.mjs';
4
3
 
5
4
  /**
@@ -25,7 +24,7 @@ async function fetchRequestHandler(opts) {
25
24
  ...innerOpts
26
25
  });
27
26
  };
28
- const url = toURL(opts.req.url);
27
+ const url = new URL(opts.req.url);
29
28
  const pathname = trimSlashes(url.pathname);
30
29
  const endpoint = trimSlashes(opts.endpoint);
31
30
  const path = trimSlashes(pathname.slice(endpoint.length));
@@ -5,6 +5,7 @@ export interface IncomingMessageWithBody extends http.IncomingMessage {
5
5
  */
6
6
  body?: unknown;
7
7
  }
8
+ export declare function createURL(req: http.IncomingMessage): URL;
8
9
  /**
9
10
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
10
11
  */
@@ -1 +1 @@
1
- {"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAIlC,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AA+CD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CA4BT"}
1
+ {"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,GAAG,CAkBxD;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAkCT"}
@@ -1,76 +1,115 @@
1
1
  'use strict';
2
2
 
3
3
  var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
4
- var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
5
4
  require('../../unstable-core-do-not-import/rootConfig.js');
6
5
 
7
- /**
8
- * Convert an incoming message to a body stream with a max size
9
- */ function incomingMessageToBodyStream(req, opts) {
6
+ function createBody(req, opts) {
7
+ // Some adapters will pre-parse the body and add it to the request object
8
+ if ('body' in req) {
9
+ // If the body is already a string, return it directly
10
+ if (typeof req.body === 'string') {
11
+ return req.body;
12
+ } else if (req.body !== undefined) {
13
+ return JSON.stringify(req.body);
14
+ }
15
+ // If body property exists but is undefined, return undefined
16
+ return undefined;
17
+ }
10
18
  let size = 0;
11
- const maxBodySize = opts.maxBodySize;
12
19
  let hasClosed = false;
13
- const stream = new ReadableStream({
20
+ return new ReadableStream({
14
21
  start (controller) {
15
- req.on('data', (chunk)=>{
22
+ const onData = (chunk)=>{
16
23
  size += chunk.length;
17
- if (maxBodySize != null && size > maxBodySize) {
18
- controller.error(new TRPCError.TRPCError({
19
- code: 'PAYLOAD_TOO_LARGE'
20
- }));
21
- // an error is thrown if we try to close the controller after
22
- // erroring, so track the closure
23
- hasClosed = true;
24
+ if (!opts.maxBodySize || size <= opts.maxBodySize) {
25
+ controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
24
26
  return;
25
27
  }
26
- controller.enqueue(chunk);
27
- });
28
- req.once('end', ()=>{
28
+ controller.error(new TRPCError.TRPCError({
29
+ code: 'PAYLOAD_TOO_LARGE'
30
+ }));
31
+ hasClosed = true;
32
+ req.off('data', onData);
33
+ req.off('end', onEnd);
34
+ };
35
+ const onEnd = ()=>{
29
36
  if (hasClosed) {
30
37
  return;
31
38
  }
32
39
  hasClosed = true;
40
+ req.off('data', onData);
41
+ req.off('end', onEnd);
33
42
  controller.close();
34
- });
43
+ };
44
+ req.on('data', onData);
45
+ req.on('end', onEnd);
35
46
  },
36
47
  cancel () {
37
48
  req.destroy();
38
49
  }
39
50
  });
40
- return stream;
41
51
  }
42
- const bodyMethods = [
43
- 'POST',
44
- 'PUT',
45
- 'PATCH'
46
- ];
52
+ function createURL(req) {
53
+ try {
54
+ const protocol = req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
55
+ const host = req.headers.host ?? 'localhost';
56
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
+ return new URL(req.url, `${protocol}//${host}`);
58
+ } catch (cause) {
59
+ throw new TRPCError.TRPCError({
60
+ code: 'BAD_REQUEST',
61
+ message: 'Invalid URL',
62
+ cause
63
+ });
64
+ }
65
+ }
66
+ function createHeaders(incoming) {
67
+ const headers = new Headers();
68
+ for(const key in incoming){
69
+ const value = incoming[key];
70
+ if (typeof key === 'string' && key.startsWith(':')) {
71
+ continue;
72
+ }
73
+ if (Array.isArray(value)) {
74
+ for (const item of value){
75
+ headers.append(key, item);
76
+ }
77
+ } else if (value != null) {
78
+ headers.append(key, value);
79
+ }
80
+ }
81
+ return headers;
82
+ }
47
83
  /**
48
84
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
49
85
  */ function incomingMessageToRequest(req, opts) {
50
86
  const ac = new AbortController();
51
- const headers = new Headers(req.headers);
52
- const url = toURL.toURL(`http://${headers.get('host')}${req.url}`);
53
- req.once('aborted', ()=>{
87
+ const onAbort = ()=>{
54
88
  ac.abort();
55
- });
89
+ req.off('aborted', onAbort);
90
+ req.off('close', onAbort);
91
+ };
92
+ req.once('aborted', onAbort);
93
+ req.socket?.once('close', onAbort);
94
+ // Get host from either regular header or HTTP/2 pseudo-header
95
+ const url = createURL(req);
56
96
  const init = {
57
- headers,
97
+ headers: createHeaders(req.headers),
58
98
  method: req.method,
59
- signal: ac.signal,
60
- // @ts-expect-error this is fine
61
- duplex: 'half'
99
+ signal: ac.signal
62
100
  };
63
- if (req.method && bodyMethods.includes(req.method)) {
64
- if (!('body' in req)) {
65
- init.body = incomingMessageToBodyStream(req, opts);
66
- } else if (typeof req.body === 'string') {
67
- init.body = req.body;
68
- } else if (req.body !== undefined) {
69
- init.body = JSON.stringify(req.body);
70
- }
101
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
102
+ init.body = createBody(req, opts);
103
+ // init.duplex = 'half' must be set when body is a ReadableStream, and Node follows the spec.
104
+ // However, this property is not defined in the TypeScript types for RequestInit, so we have
105
+ // to cast it here in order to set it without a type error.
106
+ // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex
107
+ // @ts-expect-error this is fine
108
+ init.duplex = 'half';
71
109
  }
72
110
  const request = new Request(url, init);
73
111
  return request;
74
112
  }
75
113
 
114
+ exports.createURL = createURL;
76
115
  exports.incomingMessageToRequest = incomingMessageToRequest;
@@ -1,74 +1,112 @@
1
1
  import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
2
- import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
3
2
  import '../../unstable-core-do-not-import/rootConfig.mjs';
4
3
 
5
- /**
6
- * Convert an incoming message to a body stream with a max size
7
- */ function incomingMessageToBodyStream(req, opts) {
4
+ function createBody(req, opts) {
5
+ // Some adapters will pre-parse the body and add it to the request object
6
+ if ('body' in req) {
7
+ // If the body is already a string, return it directly
8
+ if (typeof req.body === 'string') {
9
+ return req.body;
10
+ } else if (req.body !== undefined) {
11
+ return JSON.stringify(req.body);
12
+ }
13
+ // If body property exists but is undefined, return undefined
14
+ return undefined;
15
+ }
8
16
  let size = 0;
9
- const maxBodySize = opts.maxBodySize;
10
17
  let hasClosed = false;
11
- const stream = new ReadableStream({
18
+ return new ReadableStream({
12
19
  start (controller) {
13
- req.on('data', (chunk)=>{
20
+ const onData = (chunk)=>{
14
21
  size += chunk.length;
15
- if (maxBodySize != null && size > maxBodySize) {
16
- controller.error(new TRPCError({
17
- code: 'PAYLOAD_TOO_LARGE'
18
- }));
19
- // an error is thrown if we try to close the controller after
20
- // erroring, so track the closure
21
- hasClosed = true;
22
+ if (!opts.maxBodySize || size <= opts.maxBodySize) {
23
+ controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
22
24
  return;
23
25
  }
24
- controller.enqueue(chunk);
25
- });
26
- req.once('end', ()=>{
26
+ controller.error(new TRPCError({
27
+ code: 'PAYLOAD_TOO_LARGE'
28
+ }));
29
+ hasClosed = true;
30
+ req.off('data', onData);
31
+ req.off('end', onEnd);
32
+ };
33
+ const onEnd = ()=>{
27
34
  if (hasClosed) {
28
35
  return;
29
36
  }
30
37
  hasClosed = true;
38
+ req.off('data', onData);
39
+ req.off('end', onEnd);
31
40
  controller.close();
32
- });
41
+ };
42
+ req.on('data', onData);
43
+ req.on('end', onEnd);
33
44
  },
34
45
  cancel () {
35
46
  req.destroy();
36
47
  }
37
48
  });
38
- return stream;
39
49
  }
40
- const bodyMethods = [
41
- 'POST',
42
- 'PUT',
43
- 'PATCH'
44
- ];
50
+ function createURL(req) {
51
+ try {
52
+ const protocol = req.socket && 'encrypted' in req.socket && req.socket.encrypted ? 'https:' : 'http:';
53
+ const host = req.headers.host ?? 'localhost';
54
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
55
+ return new URL(req.url, `${protocol}//${host}`);
56
+ } catch (cause) {
57
+ throw new TRPCError({
58
+ code: 'BAD_REQUEST',
59
+ message: 'Invalid URL',
60
+ cause
61
+ });
62
+ }
63
+ }
64
+ function createHeaders(incoming) {
65
+ const headers = new Headers();
66
+ for(const key in incoming){
67
+ const value = incoming[key];
68
+ if (typeof key === 'string' && key.startsWith(':')) {
69
+ continue;
70
+ }
71
+ if (Array.isArray(value)) {
72
+ for (const item of value){
73
+ headers.append(key, item);
74
+ }
75
+ } else if (value != null) {
76
+ headers.append(key, value);
77
+ }
78
+ }
79
+ return headers;
80
+ }
45
81
  /**
46
82
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
47
83
  */ function incomingMessageToRequest(req, opts) {
48
84
  const ac = new AbortController();
49
- const headers = new Headers(req.headers);
50
- const url = toURL(`http://${headers.get('host')}${req.url}`);
51
- req.once('aborted', ()=>{
85
+ const onAbort = ()=>{
52
86
  ac.abort();
53
- });
87
+ req.off('aborted', onAbort);
88
+ req.off('close', onAbort);
89
+ };
90
+ req.once('aborted', onAbort);
91
+ req.socket?.once('close', onAbort);
92
+ // Get host from either regular header or HTTP/2 pseudo-header
93
+ const url = createURL(req);
54
94
  const init = {
55
- headers,
95
+ headers: createHeaders(req.headers),
56
96
  method: req.method,
57
- signal: ac.signal,
58
- // @ts-expect-error this is fine
59
- duplex: 'half'
97
+ signal: ac.signal
60
98
  };
61
- if (req.method && bodyMethods.includes(req.method)) {
62
- if (!('body' in req)) {
63
- init.body = incomingMessageToBodyStream(req, opts);
64
- } else if (typeof req.body === 'string') {
65
- init.body = req.body;
66
- } else if (req.body !== undefined) {
67
- init.body = JSON.stringify(req.body);
68
- }
99
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
100
+ init.body = createBody(req, opts);
101
+ // init.duplex = 'half' must be set when body is a ReadableStream, and Node follows the spec.
102
+ // However, this property is not defined in the TypeScript types for RequestInit, so we have
103
+ // to cast it here in order to set it without a type error.
104
+ // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex
105
+ // @ts-expect-error this is fine
106
+ init.duplex = 'half';
69
107
  }
70
108
  const request = new Request(url, init);
71
109
  return request;
72
110
  }
73
111
 
74
- export { incomingMessageToRequest };
112
+ export { createURL, incomingMessageToRequest };
@@ -7,4 +7,5 @@ var incomingMessageToRequest = require('./incomingMessageToRequest.js');
7
7
 
8
8
  exports.internal_exceptionHandler = nodeHTTPRequestHandler.internal_exceptionHandler;
9
9
  exports.nodeHTTPRequestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
10
+ exports.createURL = incomingMessageToRequest.createURL;
10
11
  exports.incomingMessageToRequest = incomingMessageToRequest.incomingMessageToRequest;
@@ -1,2 +1,2 @@
1
1
  export { internal_exceptionHandler, nodeHTTPRequestHandler } from './nodeHTTPRequestHandler.mjs';
2
- export { incomingMessageToRequest } from './incomingMessageToRequest.mjs';
2
+ export { createURL, incomingMessageToRequest } from './incomingMessageToRequest.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"m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ACzD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACtC,IAAI,CAAC,eAAe,CAyBtB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,wEAGxC"}
@@ -2,9 +2,9 @@
2
2
 
3
3
  var http = require('node:http');
4
4
  var utils = require('../unstable-core-do-not-import/utils.js');
5
- var toURL = require('../unstable-core-do-not-import/http/toURL.js');
6
5
  require('../unstable-core-do-not-import/rootConfig.js');
7
6
  var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
7
+ var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js');
8
8
 
9
9
  /**
10
10
  * @internal
@@ -12,7 +12,7 @@ var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
12
12
  return (req, res)=>{
13
13
  let path = '';
14
14
  utils.run(async ()=>{
15
- const url = toURL.toURL(req.url);
15
+ const url = incomingMessageToRequest.createURL(req);
16
16
  // get procedure path and remove the leading slash
17
17
  // /procedure -> procedure
18
18
  path = url.pathname.slice(1);
@@ -1,8 +1,8 @@
1
1
  import http from 'node:http';
2
2
  import { run } from '../unstable-core-do-not-import/utils.mjs';
3
- import { toURL } from '../unstable-core-do-not-import/http/toURL.mjs';
4
3
  import '../unstable-core-do-not-import/rootConfig.mjs';
5
4
  import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/nodeHTTPRequestHandler.mjs';
5
+ import { createURL } from './node-http/incomingMessageToRequest.mjs';
6
6
 
7
7
  /**
8
8
  * @internal
@@ -10,7 +10,7 @@ import { nodeHTTPRequestHandler, internal_exceptionHandler } from './node-http/n
10
10
  return (req, res)=>{
11
11
  let path = '';
12
12
  run(async ()=>{
13
- const url = toURL(req.url);
13
+ const url = createURL(req);
14
14
  // get procedure path and remove the leading slash
15
15
  // /procedure -> procedure
16
16
  path = url.pathname.slice(1);
@@ -3,7 +3,7 @@ import type ws from 'ws';
3
3
  import type { AnyRouter, CreateContextCallback, inferRouterContext } from '../@trpc/server';
4
4
  import { type BaseHandlerOptions } from '../@trpc/server/http';
5
5
  import { type MaybePromise } from '../unstable-core-do-not-import';
6
- import type { NodeHTTPCreateContextFnOptions } from './node-http';
6
+ import { type NodeHTTPCreateContextFnOptions } from './node-http';
7
7
  /**
8
8
  * @public
9
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAatE,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CACpE,eAAe,EACf,EAAE,CAAC,SAAS,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE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,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,YAKV,EAAE,CAAC,SAAS,OAAO,eAAe,mBAqYzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,EAAE,CAAC,SAAS,EACpB,MAAM,SAAS,EACf,UAAU,SAAQ,QAiCnB;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAwCjC"}
@@ -9,9 +9,9 @@ var observable = require('../observable/observable.js');
9
9
  var unpromise = require('../vendor/unpromise/unpromise.js');
10
10
  var tracked = require('../unstable-core-do-not-import/stream/tracked.js');
11
11
  var transformer = require('../unstable-core-do-not-import/transformer.js');
12
- var toURL = require('../unstable-core-do-not-import/http/toURL.js');
13
12
  require('../unstable-core-do-not-import/rootConfig.js');
14
13
  var router = require('../unstable-core-do-not-import/router.js');
14
+ var incomingMessageToRequest = require('./node-http/incomingMessageToRequest.js');
15
15
 
16
16
  /**
17
17
  * Importing ws causes a build error
@@ -80,7 +80,7 @@ function getWSConnectionHandler(opts) {
80
80
  *
81
81
  * - the context promise will be created immediately on connection if no connectionParams are expected
82
82
  * - if connection params are expected, they will be created once received
83
- */ let ctxPromise = toURL.toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
83
+ */ let ctxPromise = incomingMessageToRequest.createURL(req).searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
84
84
  async function handleRequest(msg) {
85
85
  const { id , jsonrpc } = msg;
86
86
  /* istanbul ignore next -- @preserve */ if (id === null) {
@@ -7,9 +7,9 @@ import { isObservable, observableToAsyncIterable } from '../observable/observabl
7
7
  import { Unpromise } from '../vendor/unpromise/unpromise.mjs';
8
8
  import { isTrackedEnvelope } from '../unstable-core-do-not-import/stream/tracked.mjs';
9
9
  import { transformTRPCResponse } from '../unstable-core-do-not-import/transformer.mjs';
10
- import { toURL } from '../unstable-core-do-not-import/http/toURL.mjs';
11
10
  import '../unstable-core-do-not-import/rootConfig.mjs';
12
11
  import { callProcedure } from '../unstable-core-do-not-import/router.mjs';
12
+ import { createURL } from './node-http/incomingMessageToRequest.mjs';
13
13
 
14
14
  /**
15
15
  * Importing ws causes a build error
@@ -78,7 +78,7 @@ function getWSConnectionHandler(opts) {
78
78
  *
79
79
  * - the context promise will be created immediately on connection if no connectionParams are expected
80
80
  * - if connection params are expected, they will be created once received
81
- */ let ctxPromise = toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
81
+ */ let ctxPromise = createURL(req).searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
82
82
  async function handleRequest(msg) {
83
83
  const { id , jsonrpc } = msg;
84
84
  /* istanbul ignore next -- @preserve */ if (id === null) {