@trpc/server 11.0.0-next-beta.260 → 11.0.0-next-beta.262
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/@trpc/server/http.d.ts +1 -0
- package/dist/@trpc/server/http.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
- package/dist/adapters/fetch/fetchRequestHandler.js +2 -1
- package/dist/adapters/fetch/fetchRequestHandler.mjs +2 -1
- package/dist/adapters/standalone.d.ts.map +1 -1
- package/dist/adapters/standalone.js +7 -3
- package/dist/adapters/standalone.mjs +7 -3
- package/dist/bundle-analysis.json +45 -33
- package/dist/http.js +2 -0
- package/dist/http.mjs +1 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts +1 -0
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/toURL.d.ts +2 -0
- package/dist/unstable-core-do-not-import/http/toURL.d.ts.map +1 -0
- package/dist/unstable-core-do-not-import/http/toURL.js +8 -0
- package/dist/unstable-core-do-not-import/http/toURL.mjs +6 -0
- package/dist/unstable-core-do-not-import.js +2 -0
- package/dist/unstable-core-do-not-import.mjs +1 -0
- package/package.json +2 -2
- package/src/@trpc/server/http.ts +1 -0
- package/src/adapters/fetch/fetchRequestHandler.ts +3 -1
- package/src/adapters/standalone.ts +6 -3
- package/src/unstable-core-do-not-import/http/index.ts +2 -0
- package/src/unstable-core-do-not-import/http/toURL.ts +7 -0
|
@@ -4,4 +4,5 @@ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPReque
|
|
|
4
4
|
export { getBatchStreamFormatter } from '../../unstable-core-do-not-import';
|
|
5
5
|
export type { BaseContentTypeHandler, BodyResult, } from '../../unstable-core-do-not-import';
|
|
6
6
|
export { getJsonContentTypeInputs } from '../../unstable-core-do-not-import';
|
|
7
|
+
export { toURL } from '../../unstable-core-do-not-import';
|
|
7
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,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,YAAY,EACV,sBAAsB,EACtB,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,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,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,YAAY,EACV,sBAAsB,EACtB,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"fetchRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fetch/fetchRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAYpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,mBAAmB,CAAC,OAAO,CAAC,GAAG;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AASJ,wBAAsB,mBAAmB,CAAC,OAAO,SAAS,SAAS,EACjE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,GACxC,OAAO,CAAC,QAAQ,CAAC,CAyGnB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require('../../unstable-core-do-not-import/rpc/codes.js');
|
|
4
4
|
var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
5
5
|
var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
6
|
+
var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
|
|
6
7
|
require('../../unstable-core-do-not-import/rootConfig.js');
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -28,7 +29,7 @@ async function fetchRequestHandler(opts) {
|
|
|
28
29
|
...innerOpts
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
|
-
const url =
|
|
32
|
+
const url = toURL.toURL(opts.req.url);
|
|
32
33
|
const pathname = trimSlashes(url.pathname);
|
|
33
34
|
const endpoint = trimSlashes(opts.endpoint);
|
|
34
35
|
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import '../../unstable-core-do-not-import/rpc/codes.mjs';
|
|
2
2
|
import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
3
3
|
import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
4
|
+
import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
|
|
4
5
|
import '../../unstable-core-do-not-import/rootConfig.mjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -26,7 +27,7 @@ async function fetchRequestHandler(opts) {
|
|
|
26
27
|
...innerOpts
|
|
27
28
|
});
|
|
28
29
|
};
|
|
29
|
-
const url =
|
|
30
|
+
const url = toURL(opts.req.url);
|
|
30
31
|
const pathname = trimSlashes(url.pathname);
|
|
31
32
|
const endpoint = trimSlashes(opts.endpoint);
|
|
32
33
|
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../src/adapters/standalone.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;AAE7E,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,CACnE,IAAI,CAAC,eAAe,EACpB,IAAI,CAAC,cAAc,CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,SAEpB,KAAK,eAAe,OAAO,KAAK,cAAc,mBAgBlE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EACxD,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,wEAIxC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var http = require('node:http');
|
|
4
|
+
require('../unstable-core-do-not-import/rpc/codes.js');
|
|
5
|
+
var toURL = require('../unstable-core-do-not-import/http/toURL.js');
|
|
6
|
+
require('../unstable-core-do-not-import/rootConfig.js');
|
|
4
7
|
var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
|
|
5
8
|
|
|
6
9
|
function createHTTPHandler(opts) {
|
|
7
10
|
return async (req, res)=>{
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
+
const url = toURL.toURL(req.url);
|
|
12
|
+
// get procedure path and remove the leading slash
|
|
13
|
+
// /procedure -> procedure
|
|
14
|
+
const path = url.pathname.slice(1);
|
|
11
15
|
await nodeHTTPRequestHandler.nodeHTTPRequestHandler({
|
|
12
16
|
// FIXME: no typecasting should be needed here
|
|
13
17
|
...opts,
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import http from 'node:http';
|
|
2
|
+
import '../unstable-core-do-not-import/rpc/codes.mjs';
|
|
3
|
+
import { toURL } from '../unstable-core-do-not-import/http/toURL.mjs';
|
|
4
|
+
import '../unstable-core-do-not-import/rootConfig.mjs';
|
|
2
5
|
import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
|
|
3
6
|
|
|
4
7
|
function createHTTPHandler(opts) {
|
|
5
8
|
return async (req, res)=>{
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
+
const url = toURL(req.url);
|
|
10
|
+
// get procedure path and remove the leading slash
|
|
11
|
+
// /procedure -> procedure
|
|
12
|
+
const path = url.pathname.slice(1);
|
|
9
13
|
await nodeHTTPRequestHandler({
|
|
10
14
|
// FIXME: no typecasting should be needed here
|
|
11
15
|
...opts,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
2
|
+
"bundleSize": 92119,
|
|
3
|
+
"bundleOrigSize": 145006,
|
|
4
4
|
"bundleReduction": 36.47,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 10.
|
|
17
|
+
"percent": 10.72,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"removedExports": [],
|
|
28
28
|
"dependents": [],
|
|
29
|
-
"percent": 10.
|
|
29
|
+
"percent": 10.05,
|
|
30
30
|
"reduction": 21.53
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
46
46
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
47
47
|
],
|
|
48
|
-
"percent": 6.
|
|
48
|
+
"percent": 6.56,
|
|
49
49
|
"reduction": 37.21
|
|
50
50
|
},
|
|
51
51
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 6.
|
|
64
|
+
"percent": 6.08,
|
|
65
65
|
"reduction": 51.52
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"dependents": [
|
|
78
78
|
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
79
79
|
],
|
|
80
|
-
"percent": 5.
|
|
80
|
+
"percent": 5.4,
|
|
81
81
|
"reduction": 36.77
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -105,13 +105,13 @@
|
|
|
105
105
|
"dependents": [
|
|
106
106
|
"/src/adapters/node-http/index.ts"
|
|
107
107
|
],
|
|
108
|
-
"percent": 4.
|
|
108
|
+
"percent": 4.4,
|
|
109
109
|
"reduction": 12.45
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"id": "/src/adapters/fetch/fetchRequestHandler.ts",
|
|
113
|
-
"size":
|
|
114
|
-
"origSize":
|
|
113
|
+
"size": 3554,
|
|
114
|
+
"origSize": 3927,
|
|
115
115
|
"renderedExports": [
|
|
116
116
|
"fetchRequestHandler"
|
|
117
117
|
],
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"/src/adapters/fetch/index.ts"
|
|
121
121
|
],
|
|
122
122
|
"percent": 3.86,
|
|
123
|
-
"reduction": 9.
|
|
123
|
+
"reduction": 9.5
|
|
124
124
|
},
|
|
125
125
|
{
|
|
126
126
|
"id": "/src/observable/observable.ts",
|
|
@@ -135,7 +135,7 @@
|
|
|
135
135
|
"dependents": [
|
|
136
136
|
"/src/observable/index.ts"
|
|
137
137
|
],
|
|
138
|
-
"percent": 3.
|
|
138
|
+
"percent": 3.72,
|
|
139
139
|
"reduction": 5.43
|
|
140
140
|
},
|
|
141
141
|
{
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"dependents": [
|
|
155
155
|
"/src/adapters/aws-lambda/index.ts"
|
|
156
156
|
],
|
|
157
|
-
"percent": 3.
|
|
157
|
+
"percent": 3.59,
|
|
158
158
|
"reduction": 36.48
|
|
159
159
|
},
|
|
160
160
|
{
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
"dependents": [
|
|
171
171
|
"/src/observable/index.ts"
|
|
172
172
|
],
|
|
173
|
-
"percent": 3.
|
|
173
|
+
"percent": 3.23,
|
|
174
174
|
"reduction": 0
|
|
175
175
|
},
|
|
176
176
|
{
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"/src/adapters/fastify/index.ts",
|
|
220
220
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
221
221
|
],
|
|
222
|
-
"percent": 2.
|
|
222
|
+
"percent": 2.81,
|
|
223
223
|
"reduction": 35.33
|
|
224
224
|
},
|
|
225
225
|
{
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
"dependents": [
|
|
386
386
|
"/src/adapters/node-http/content-type/json/index.ts"
|
|
387
387
|
],
|
|
388
|
-
"percent": 1.
|
|
388
|
+
"percent": 1.21,
|
|
389
389
|
"reduction": 2.87
|
|
390
390
|
},
|
|
391
391
|
{
|
|
@@ -483,22 +483,9 @@
|
|
|
483
483
|
],
|
|
484
484
|
"removedExports": [],
|
|
485
485
|
"dependents": [],
|
|
486
|
-
"percent": 0.
|
|
486
|
+
"percent": 0.72,
|
|
487
487
|
"reduction": 0.6
|
|
488
488
|
},
|
|
489
|
-
{
|
|
490
|
-
"id": "/src/adapters/standalone.ts",
|
|
491
|
-
"size": 637,
|
|
492
|
-
"origSize": 1689,
|
|
493
|
-
"renderedExports": [
|
|
494
|
-
"createHTTPHandler",
|
|
495
|
-
"createHTTPServer"
|
|
496
|
-
],
|
|
497
|
-
"removedExports": [],
|
|
498
|
-
"dependents": [],
|
|
499
|
-
"percent": 0.69,
|
|
500
|
-
"reduction": 62.29
|
|
501
|
-
},
|
|
502
489
|
{
|
|
503
490
|
"id": "/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
504
491
|
"size": 625,
|
|
@@ -514,6 +501,19 @@
|
|
|
514
501
|
"percent": 0.68,
|
|
515
502
|
"reduction": 43.49
|
|
516
503
|
},
|
|
504
|
+
{
|
|
505
|
+
"id": "/src/adapters/standalone.ts",
|
|
506
|
+
"size": 600,
|
|
507
|
+
"origSize": 1689,
|
|
508
|
+
"renderedExports": [
|
|
509
|
+
"createHTTPHandler",
|
|
510
|
+
"createHTTPServer"
|
|
511
|
+
],
|
|
512
|
+
"removedExports": [],
|
|
513
|
+
"dependents": [],
|
|
514
|
+
"percent": 0.65,
|
|
515
|
+
"reduction": 64.48
|
|
516
|
+
},
|
|
517
517
|
{
|
|
518
518
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
519
519
|
"size": 343,
|
|
@@ -569,6 +569,18 @@
|
|
|
569
569
|
"percent": 0.24,
|
|
570
570
|
"reduction": 94.55
|
|
571
571
|
},
|
|
572
|
+
{
|
|
573
|
+
"id": "/src/unstable-core-do-not-import/http/toURL.ts",
|
|
574
|
+
"size": 158,
|
|
575
|
+
"origSize": 184,
|
|
576
|
+
"renderedExports": [
|
|
577
|
+
"toURL"
|
|
578
|
+
],
|
|
579
|
+
"removedExports": [],
|
|
580
|
+
"dependents": [],
|
|
581
|
+
"percent": 0.17,
|
|
582
|
+
"reduction": 14.13
|
|
583
|
+
},
|
|
572
584
|
{
|
|
573
585
|
"id": "/src/adapters/node-http/internals/contentType.ts",
|
|
574
586
|
"size": 116,
|
|
@@ -578,8 +590,8 @@
|
|
|
578
590
|
],
|
|
579
591
|
"removedExports": [],
|
|
580
592
|
"dependents": [
|
|
581
|
-
"/src/adapters/node-http/content-type/
|
|
582
|
-
"/src/adapters/node-http/content-type/
|
|
593
|
+
"/src/adapters/node-http/content-type/json/index.ts",
|
|
594
|
+
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
583
595
|
],
|
|
584
596
|
"percent": 0.13,
|
|
585
597
|
"reduction": 86.68
|
|
@@ -712,5 +724,5 @@
|
|
|
712
724
|
"reduction": 100
|
|
713
725
|
}
|
|
714
726
|
],
|
|
715
|
-
"moduleCount":
|
|
727
|
+
"moduleCount": 50
|
|
716
728
|
}
|
package/dist/http.js
CHANGED
|
@@ -5,6 +5,7 @@ require('./unstable-core-do-not-import/rpc/codes.js');
|
|
|
5
5
|
var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
6
6
|
var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
7
7
|
var contentType = require('./unstable-core-do-not-import/http/contentType.js');
|
|
8
|
+
var toURL = require('./unstable-core-do-not-import/http/toURL.js');
|
|
8
9
|
require('./unstable-core-do-not-import/rootConfig.js');
|
|
9
10
|
|
|
10
11
|
|
|
@@ -14,3 +15,4 @@ exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromErro
|
|
|
14
15
|
exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
|
|
15
16
|
exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
|
|
16
17
|
exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
|
|
18
|
+
exports.toURL = toURL.toURL;
|
package/dist/http.mjs
CHANGED
|
@@ -3,4 +3,5 @@ import './unstable-core-do-not-import/rpc/codes.mjs';
|
|
|
3
3
|
export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
4
4
|
export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
5
5
|
export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
|
|
6
|
+
export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
|
|
6
7
|
import './unstable-core-do-not-import/rootConfig.mjs';
|
|
@@ -4,4 +4,5 @@ export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPReque
|
|
|
4
4
|
export { getBatchStreamFormatter } from './batchStreamFormatter';
|
|
5
5
|
export type { BaseContentTypeHandler, BodyResult } from './contentType';
|
|
6
6
|
export { getJsonContentTypeInputs } from './contentType';
|
|
7
|
+
export { toURL } from './toURL';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toURL.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/toURL.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,aAAa,EAAE,MAAM,GAAG,GAAG,CAMhD"}
|
|
@@ -8,6 +8,7 @@ var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatu
|
|
|
8
8
|
var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
|
|
9
9
|
var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
|
|
10
10
|
var contentType = require('./unstable-core-do-not-import/http/contentType.js');
|
|
11
|
+
var toURL = require('./unstable-core-do-not-import/http/toURL.js');
|
|
11
12
|
var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
|
|
12
13
|
var middleware = require('./unstable-core-do-not-import/middleware.js');
|
|
13
14
|
var parser = require('./unstable-core-do-not-import/parser.js');
|
|
@@ -35,6 +36,7 @@ exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromErro
|
|
|
35
36
|
exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
|
|
36
37
|
exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
|
|
37
38
|
exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
|
|
39
|
+
exports.toURL = toURL.toURL;
|
|
38
40
|
exports.initTRPC = initTRPC.initTRPC;
|
|
39
41
|
exports.createInputMiddleware = middleware.createInputMiddleware;
|
|
40
42
|
exports.createMiddlewareFactory = middleware.createMiddlewareFactory;
|
|
@@ -6,6 +6,7 @@ export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-d
|
|
|
6
6
|
export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
|
|
7
7
|
export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
|
|
8
8
|
export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
|
|
9
|
+
export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
|
|
9
10
|
export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
|
|
10
11
|
export { createInputMiddleware, createMiddlewareFactory, createOutputMiddleware, experimental_standaloneMiddleware, middlewareMarker } from './unstable-core-do-not-import/middleware.mjs';
|
|
11
12
|
export { getParseFn } from './unstable-core-do-not-import/parser.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-next-beta.
|
|
3
|
+
"version": "11.0.0-next-beta.262+4855abdcd",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"funding": [
|
|
158
158
|
"https://trpc.io/sponsor"
|
|
159
159
|
],
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "4855abdcd6e6b8dca910011a6b1827a1257e8023"
|
|
161
161
|
}
|
package/src/@trpc/server/http.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
10
|
// @trpc/server
|
|
11
|
+
|
|
11
12
|
import type { AnyRouter } from '../../@trpc/server';
|
|
12
13
|
import type {
|
|
13
14
|
HTTPRequest,
|
|
@@ -18,6 +19,7 @@ import type {
|
|
|
18
19
|
import {
|
|
19
20
|
getBatchStreamFormatter,
|
|
20
21
|
resolveHTTPResponse,
|
|
22
|
+
toURL,
|
|
21
23
|
} from '../../@trpc/server/http';
|
|
22
24
|
import type { FetchHandlerOptions } from './types';
|
|
23
25
|
|
|
@@ -45,7 +47,7 @@ export async function fetchRequestHandler<TRouter extends AnyRouter>(
|
|
|
45
47
|
return opts.createContext?.({ req: opts.req, resHeaders, ...innerOpts });
|
|
46
48
|
};
|
|
47
49
|
|
|
48
|
-
const url =
|
|
50
|
+
const url = toURL(opts.req.url);
|
|
49
51
|
|
|
50
52
|
const pathname = trimSlashes(url.pathname);
|
|
51
53
|
const endpoint = trimSlashes(opts.endpoint);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import http from 'http';
|
|
12
12
|
// @trpc/server
|
|
13
13
|
import type { AnyRouter } from '../@trpc/server';
|
|
14
|
+
import { toURL } from '../@trpc/server/http';
|
|
14
15
|
import type {
|
|
15
16
|
NodeHTTPCreateContextFnOptions,
|
|
16
17
|
NodeHTTPHandlerOptions,
|
|
@@ -29,9 +30,11 @@ export function createHTTPHandler<TRouter extends AnyRouter>(
|
|
|
29
30
|
opts: CreateHTTPHandlerOptions<TRouter>,
|
|
30
31
|
) {
|
|
31
32
|
return async (req: http.IncomingMessage, res: http.ServerResponse) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const url = toURL(req.url!);
|
|
34
|
+
|
|
35
|
+
// get procedure path and remove the leading slash
|
|
36
|
+
// /procedure -> procedure
|
|
37
|
+
const path = url.pathname.slice(1);
|
|
35
38
|
|
|
36
39
|
await nodeHTTPRequestHandler({
|
|
37
40
|
// FIXME: no typecasting should be needed here
|