@trpc/server 11.0.0-alpha-tmp-02-04-resolver-alt.279 → 11.0.0-alpha-tmp-02-08-tmp.274

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAKnE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAkC5B"}
1
+ {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAKnE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAoC5B"}
@@ -20,6 +20,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
20
20
  _done(null, body);
21
21
  });
22
22
  let prefix = opts.prefix ?? '';
23
+ const websocketPrefix = prefix;
23
24
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
24
25
  // @ts-expect-error property 'default' does not exists on type ...
25
26
  if (typeof fastifyTRPCPlugin.default !== 'function') {
@@ -37,6 +38,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
37
38
  if (opts.useWSS) {
38
39
  ws.applyWSSHandler({
39
40
  ...opts.trpcOptions,
41
+ prefix: websocketPrefix,
40
42
  wss: fastify.websocketServer
41
43
  });
42
44
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -18,6 +18,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
18
18
  _done(null, body);
19
19
  });
20
20
  let prefix = opts.prefix ?? '';
21
+ const websocketPrefix = prefix;
21
22
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
22
23
  // @ts-expect-error property 'default' does not exists on type ...
23
24
  if (typeof fastifyTRPCPlugin.default !== 'function') {
@@ -35,6 +36,7 @@ function fastifyTRPCPlugin(fastify, opts, done) {
35
36
  if (opts.useWSS) {
36
37
  applyWSSHandler({
37
38
  ...opts.trpcOptions,
39
+ prefix: websocketPrefix,
38
40
  wss: fastify.websocketServer
39
41
  });
40
42
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -31,6 +31,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<TR
31
31
  }) & {
32
32
  wss: ws.WebSocketServer;
33
33
  process?: NodeJS.Process;
34
+ prefix?: string;
34
35
  };
35
36
  export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
36
37
  broadcastReconnectNotification: () => void;
@@ -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,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAQrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,8BAA8B,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,EAC7D,MAAM,CACP,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;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,eAAe,CAChB,GACC,CAAC,MAAM,SAAS,kBAAkB,CAAC,OAAO,CAAC,GACvC;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC7C,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAAC,GAAG;IACP,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;CAC1B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EAwQjC"}
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,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAQrE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,8BAA8B,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,EAC7D,MAAM,CACP,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;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,kBAAkB,CAC3E,OAAO,EACP,eAAe,CAChB,GACC,CAAC,MAAM,SAAS,kBAAkB,CAAC,OAAO,CAAC,GACvC;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC7C,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CAC5C,CAAC,GAAG;IACP,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEJ,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA4QjC"}
@@ -14,9 +14,12 @@ var observable = require('../observable/observable.js');
14
14
  * @link https://github.com/trpc/trpc/pull/5279
15
15
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
16
16
  function applyWSSHandler(opts) {
17
- const { wss , createContext , router: router$1 } = opts;
17
+ const { wss , createContext , router: router$1 , prefix } = opts;
18
18
  const { transformer: transformer$1 } = router$1._def._config;
19
19
  wss.on('connection', async (client, req)=>{
20
+ if (prefix && !req.url?.startsWith(prefix)) {
21
+ return;
22
+ }
20
23
  const clientSubscriptions = new Map();
21
24
  function respond(untransformedJSON) {
22
25
  client.send(JSON.stringify(transformer.transformTRPCResponse(router$1._def._config, untransformedJSON)));
@@ -12,9 +12,12 @@ import { isObservable } from '../observable/observable.mjs';
12
12
  * @link https://github.com/trpc/trpc/pull/5279
13
13
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
14
14
  function applyWSSHandler(opts) {
15
- const { wss , createContext , router } = opts;
15
+ const { wss , createContext , router , prefix } = opts;
16
16
  const { transformer } = router._def._config;
17
17
  wss.on('connection', async (client, req)=>{
18
+ if (prefix && !req.url?.startsWith(prefix)) {
19
+ return;
20
+ }
18
21
  const clientSubscriptions = new Map();
19
22
  function respond(untransformedJSON) {
20
23
  client.send(JSON.stringify(transformTRPCResponse(router._def._config, untransformedJSON)));
@@ -0,0 +1,728 @@
1
+ {
2
+ "bundleSize": 92285,
3
+ "bundleOrigSize": 145552,
4
+ "bundleReduction": 36.6,
5
+ "modules": [
6
+ {
7
+ "id": "/src/adapters/ws.ts",
8
+ "size": 9970,
9
+ "origSize": 9269,
10
+ "renderedExports": [
11
+ "applyWSSHandler"
12
+ ],
13
+ "removedExports": [],
14
+ "dependents": [
15
+ "/src/adapters/fastify/fastifyTRPCPlugin.ts"
16
+ ],
17
+ "percent": 10.8,
18
+ "reduction": 0
19
+ },
20
+ {
21
+ "id": "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
22
+ "size": 9259,
23
+ "origSize": 11799,
24
+ "renderedExports": [
25
+ "resolveHTTPResponse"
26
+ ],
27
+ "removedExports": [],
28
+ "dependents": [],
29
+ "percent": 10.03,
30
+ "reduction": 21.53
31
+ },
32
+ {
33
+ "id": "/src/unstable-core-do-not-import/router.ts",
34
+ "size": 6040,
35
+ "origSize": 9792,
36
+ "renderedExports": [
37
+ "createRouterFactory",
38
+ "callProcedure",
39
+ "createCallerFactory",
40
+ "mergeRouters"
41
+ ],
42
+ "removedExports": [],
43
+ "dependents": [
44
+ "/src/unstable-core-do-not-import.ts",
45
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
46
+ "/src/unstable-core-do-not-import/initTRPC.ts"
47
+ ],
48
+ "percent": 6.54,
49
+ "reduction": 38.32
50
+ },
51
+ {
52
+ "id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
53
+ "size": 5602,
54
+ "origSize": 11765,
55
+ "renderedExports": [
56
+ "unsetMarker",
57
+ "createBuilder"
58
+ ],
59
+ "removedExports": [],
60
+ "dependents": [
61
+ "/src/unstable-core-do-not-import.ts",
62
+ "/src/unstable-core-do-not-import/initTRPC.ts"
63
+ ],
64
+ "percent": 6.07,
65
+ "reduction": 52.38
66
+ },
67
+ {
68
+ "id": "/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts",
69
+ "size": 4977,
70
+ "origSize": 7871,
71
+ "renderedExports": [
72
+ "readableStreamToString",
73
+ "createFileUploadHandler",
74
+ "NodeOnDiskFile"
75
+ ],
76
+ "removedExports": [],
77
+ "dependents": [
78
+ "/src/adapters/node-http/content-type/form-data/index.ts"
79
+ ],
80
+ "percent": 5.39,
81
+ "reduction": 36.77
82
+ },
83
+ {
84
+ "id": "/src/adapters/node-http/content-type/form-data/index.ts",
85
+ "size": 4420,
86
+ "origSize": 6569,
87
+ "renderedExports": [
88
+ "nodeHTTPFormDataContentTypeHandler",
89
+ "experimental_isMultipartFormDataRequest",
90
+ "experimental_parseMultipartFormData"
91
+ ],
92
+ "removedExports": [],
93
+ "dependents": [],
94
+ "percent": 4.79,
95
+ "reduction": 32.71
96
+ },
97
+ {
98
+ "id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
99
+ "size": 4056,
100
+ "origSize": 4633,
101
+ "renderedExports": [
102
+ "nodeHTTPRequestHandler"
103
+ ],
104
+ "removedExports": [],
105
+ "dependents": [
106
+ "/src/adapters/node-http/index.ts"
107
+ ],
108
+ "percent": 4.4,
109
+ "reduction": 12.45
110
+ },
111
+ {
112
+ "id": "/src/adapters/fetch/fetchRequestHandler.ts",
113
+ "size": 3554,
114
+ "origSize": 3927,
115
+ "renderedExports": [
116
+ "fetchRequestHandler"
117
+ ],
118
+ "removedExports": [],
119
+ "dependents": [
120
+ "/src/adapters/fetch/index.ts"
121
+ ],
122
+ "percent": 3.85,
123
+ "reduction": 9.5
124
+ },
125
+ {
126
+ "id": "/src/observable/observable.ts",
127
+ "size": 3430,
128
+ "origSize": 3627,
129
+ "renderedExports": [
130
+ "isObservable",
131
+ "observable",
132
+ "observableToPromise"
133
+ ],
134
+ "removedExports": [],
135
+ "dependents": [
136
+ "/src/observable/index.ts"
137
+ ],
138
+ "percent": 3.72,
139
+ "reduction": 5.43
140
+ },
141
+ {
142
+ "id": "/src/adapters/aws-lambda/utils.ts",
143
+ "size": 3308,
144
+ "origSize": 5208,
145
+ "renderedExports": [
146
+ "isPayloadV1",
147
+ "isPayloadV2",
148
+ "getHTTPMethod",
149
+ "getPath",
150
+ "transformHeaders",
151
+ "UNKNOWN_PAYLOAD_FORMAT_VERSION_ERROR_MESSAGE"
152
+ ],
153
+ "removedExports": [],
154
+ "dependents": [
155
+ "/src/adapters/aws-lambda/index.ts"
156
+ ],
157
+ "percent": 3.58,
158
+ "reduction": 36.48
159
+ },
160
+ {
161
+ "id": "/src/observable/operators.ts",
162
+ "size": 2980,
163
+ "origSize": 2812,
164
+ "renderedExports": [
165
+ "map",
166
+ "share",
167
+ "tap"
168
+ ],
169
+ "removedExports": [],
170
+ "dependents": [
171
+ "/src/observable/index.ts"
172
+ ],
173
+ "percent": 3.23,
174
+ "reduction": 0
175
+ },
176
+ {
177
+ "id": "/src/unstable-core-do-not-import/initTRPC.ts",
178
+ "size": 2879,
179
+ "origSize": 4716,
180
+ "renderedExports": [
181
+ "initTRPC"
182
+ ],
183
+ "removedExports": [],
184
+ "dependents": [
185
+ "/src/unstable-core-do-not-import.ts"
186
+ ],
187
+ "percent": 3.12,
188
+ "reduction": 38.95
189
+ },
190
+ {
191
+ "id": "/src/unstable-core-do-not-import/transformer.ts",
192
+ "size": 2744,
193
+ "origSize": 5076,
194
+ "renderedExports": [
195
+ "getDataTransformer",
196
+ "defaultTransformer",
197
+ "transformTRPCResponse",
198
+ "transformResult"
199
+ ],
200
+ "removedExports": [],
201
+ "dependents": [
202
+ "/src/unstable-core-do-not-import.ts",
203
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
204
+ "/src/unstable-core-do-not-import/router.ts",
205
+ "/src/unstable-core-do-not-import/initTRPC.ts"
206
+ ],
207
+ "percent": 2.97,
208
+ "reduction": 45.94
209
+ },
210
+ {
211
+ "id": "/src/adapters/fastify/fastifyRequestHandler.ts",
212
+ "size": 2590,
213
+ "origSize": 4005,
214
+ "renderedExports": [
215
+ "fastifyRequestHandler"
216
+ ],
217
+ "removedExports": [],
218
+ "dependents": [
219
+ "/src/adapters/fastify/index.ts",
220
+ "/src/adapters/fastify/fastifyTRPCPlugin.ts"
221
+ ],
222
+ "percent": 2.81,
223
+ "reduction": 35.33
224
+ },
225
+ {
226
+ "id": "/src/unstable-core-do-not-import/middleware.ts",
227
+ "size": 2579,
228
+ "origSize": 5855,
229
+ "renderedExports": [
230
+ "middlewareMarker",
231
+ "createMiddlewareFactory",
232
+ "experimental_standaloneMiddleware",
233
+ "createInputMiddleware",
234
+ "createOutputMiddleware"
235
+ ],
236
+ "removedExports": [],
237
+ "dependents": [
238
+ "/src/unstable-core-do-not-import.ts",
239
+ "/src/unstable-core-do-not-import/initTRPC.ts",
240
+ "/src/unstable-core-do-not-import/procedureBuilder.ts"
241
+ ],
242
+ "percent": 2.79,
243
+ "reduction": 55.95
244
+ },
245
+ {
246
+ "id": "/src/adapters/aws-lambda/index.ts",
247
+ "size": 2540,
248
+ "origSize": 3701,
249
+ "renderedExports": [
250
+ "awsLambdaRequestHandler"
251
+ ],
252
+ "removedExports": [],
253
+ "dependents": [],
254
+ "percent": 2.75,
255
+ "reduction": 31.37
256
+ },
257
+ {
258
+ "id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
259
+ "size": 1733,
260
+ "origSize": 2152,
261
+ "renderedExports": [
262
+ "getCauseFromUnknown",
263
+ "getTRPCErrorFromUnknown",
264
+ "TRPCError"
265
+ ],
266
+ "removedExports": [],
267
+ "dependents": [
268
+ "/src/unstable-core-do-not-import.ts",
269
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
270
+ "/src/unstable-core-do-not-import/http/contentType.ts",
271
+ "/src/unstable-core-do-not-import/router.ts",
272
+ "/src/unstable-core-do-not-import/middleware.ts",
273
+ "/src/unstable-core-do-not-import/procedureBuilder.ts"
274
+ ],
275
+ "percent": 1.88,
276
+ "reduction": 19.47
277
+ },
278
+ {
279
+ "id": "/src/unstable-core-do-not-import/http/contentType.ts",
280
+ "size": 1642,
281
+ "origSize": 2518,
282
+ "renderedExports": [
283
+ "getJsonContentTypeInputs"
284
+ ],
285
+ "removedExports": [],
286
+ "dependents": [
287
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
288
+ ],
289
+ "percent": 1.78,
290
+ "reduction": 34.79
291
+ },
292
+ {
293
+ "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
294
+ "size": 1603,
295
+ "origSize": 2343,
296
+ "renderedExports": [
297
+ "fastifyTRPCPlugin"
298
+ ],
299
+ "removedExports": [],
300
+ "dependents": [
301
+ "/src/adapters/fastify/index.ts"
302
+ ],
303
+ "percent": 1.74,
304
+ "reduction": 31.58
305
+ },
306
+ {
307
+ "id": "/src/adapters/next.ts",
308
+ "size": 1602,
309
+ "origSize": 2260,
310
+ "renderedExports": [
311
+ "createNextApiHandler"
312
+ ],
313
+ "removedExports": [],
314
+ "dependents": [],
315
+ "percent": 1.74,
316
+ "reduction": 29.12
317
+ },
318
+ {
319
+ "id": "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
320
+ "size": 1580,
321
+ "origSize": 2001,
322
+ "renderedExports": [
323
+ "parseTRPCMessage"
324
+ ],
325
+ "removedExports": [],
326
+ "dependents": [],
327
+ "percent": 1.71,
328
+ "reduction": 21.04
329
+ },
330
+ {
331
+ "id": "/src/unstable-core-do-not-import/createProxy.ts",
332
+ "size": 1507,
333
+ "origSize": 1596,
334
+ "renderedExports": [
335
+ "createRecursiveProxy",
336
+ "createFlatProxy"
337
+ ],
338
+ "removedExports": [],
339
+ "dependents": [
340
+ "/src/unstable-core-do-not-import.ts",
341
+ "/src/unstable-core-do-not-import/router.ts",
342
+ "/src/unstable-core-do-not-import/initTRPC.ts"
343
+ ],
344
+ "percent": 1.63,
345
+ "reduction": 5.58
346
+ },
347
+ {
348
+ "id": "/src/adapters/node-http/content-type/form-data/streamSlice.ts",
349
+ "size": 1393,
350
+ "origSize": 1370,
351
+ "renderedExports": [
352
+ "streamSlice"
353
+ ],
354
+ "removedExports": [],
355
+ "dependents": [
356
+ "/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts"
357
+ ],
358
+ "percent": 1.51,
359
+ "reduction": 0
360
+ },
361
+ {
362
+ "id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
363
+ "size": 1233,
364
+ "origSize": 1608,
365
+ "renderedExports": [
366
+ "getHTTPStatusCode",
367
+ "getHTTPStatusCodeFromError"
368
+ ],
369
+ "removedExports": [],
370
+ "dependents": [
371
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
372
+ "/src/unstable-core-do-not-import/error/getErrorShape.ts"
373
+ ],
374
+ "percent": 1.34,
375
+ "reduction": 23.32
376
+ },
377
+ {
378
+ "id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
379
+ "size": 1118,
380
+ "origSize": 1151,
381
+ "renderedExports": [
382
+ "getPostBody"
383
+ ],
384
+ "removedExports": [],
385
+ "dependents": [
386
+ "/src/adapters/node-http/content-type/json/index.ts"
387
+ ],
388
+ "percent": 1.21,
389
+ "reduction": 2.87
390
+ },
391
+ {
392
+ "id": "/src/unstable-core-do-not-import/rpc/codes.ts",
393
+ "size": 1020,
394
+ "origSize": 1325,
395
+ "renderedExports": [
396
+ "TRPC_ERROR_CODES_BY_KEY",
397
+ "TRPC_ERROR_CODES_BY_NUMBER"
398
+ ],
399
+ "removedExports": [],
400
+ "dependents": [],
401
+ "percent": 1.11,
402
+ "reduction": 23.02
403
+ },
404
+ {
405
+ "id": "/src/unstable-core-do-not-import/utils.ts",
406
+ "size": 1006,
407
+ "origSize": 1566,
408
+ "renderedExports": [
409
+ "invert",
410
+ "mergeWithoutOverrides",
411
+ "isObject",
412
+ "omitPrototype"
413
+ ],
414
+ "removedExports": [],
415
+ "dependents": [
416
+ "/src/unstable-core-do-not-import.ts",
417
+ "/src/unstable-core-do-not-import/rpc/codes.ts",
418
+ "/src/unstable-core-do-not-import/error/TRPCError.ts",
419
+ "/src/unstable-core-do-not-import/router.ts",
420
+ "/src/unstable-core-do-not-import/transformer.ts",
421
+ "/src/unstable-core-do-not-import/middleware.ts",
422
+ "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
423
+ "/src/unstable-core-do-not-import/procedureBuilder.ts"
424
+ ],
425
+ "percent": 1.09,
426
+ "reduction": 35.76
427
+ },
428
+ {
429
+ "id": "/src/unstable-core-do-not-import/parser.ts",
430
+ "size": 998,
431
+ "origSize": 2272,
432
+ "renderedExports": [
433
+ "getParseFn"
434
+ ],
435
+ "removedExports": [],
436
+ "dependents": [
437
+ "/src/unstable-core-do-not-import.ts",
438
+ "/src/unstable-core-do-not-import/procedureBuilder.ts"
439
+ ],
440
+ "percent": 1.08,
441
+ "reduction": 56.07
442
+ },
443
+ {
444
+ "id": "/src/adapters/node-http/content-type/form-data/uploadHandler.ts",
445
+ "size": 726,
446
+ "origSize": 2235,
447
+ "renderedExports": [
448
+ "composeUploadHandlers",
449
+ "MaxPartSizeExceededError",
450
+ "MaxBodySizeExceededError"
451
+ ],
452
+ "removedExports": [
453
+ "createMemoryUploadHandler"
454
+ ],
455
+ "dependents": [
456
+ "/src/adapters/node-http/content-type/form-data/index.ts",
457
+ "/src/adapters/node-http/content-type/form-data/fileUploadHandler.ts",
458
+ "/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts"
459
+ ],
460
+ "percent": 0.79,
461
+ "reduction": 67.52
462
+ },
463
+ {
464
+ "id": "/src/adapters/node-http/content-type/form-data/memoryUploadHandler.ts",
465
+ "size": 699,
466
+ "origSize": 2428,
467
+ "renderedExports": [
468
+ "createMemoryUploadHandler"
469
+ ],
470
+ "removedExports": [],
471
+ "dependents": [
472
+ "/src/adapters/node-http/content-type/form-data/index.ts"
473
+ ],
474
+ "percent": 0.76,
475
+ "reduction": 71.21
476
+ },
477
+ {
478
+ "id": "/src/unstable-core-do-not-import/http/batchStreamFormatter.ts",
479
+ "size": 667,
480
+ "origSize": 671,
481
+ "renderedExports": [
482
+ "getBatchStreamFormatter"
483
+ ],
484
+ "removedExports": [],
485
+ "dependents": [],
486
+ "percent": 0.72,
487
+ "reduction": 0.6
488
+ },
489
+ {
490
+ "id": "/src/unstable-core-do-not-import/error/getErrorShape.ts",
491
+ "size": 625,
492
+ "origSize": 1106,
493
+ "renderedExports": [
494
+ "getErrorShape"
495
+ ],
496
+ "removedExports": [],
497
+ "dependents": [
498
+ "/src/unstable-core-do-not-import.ts",
499
+ "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
500
+ ],
501
+ "percent": 0.68,
502
+ "reduction": 43.49
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
+ {
518
+ "id": "/src/unstable-core-do-not-import/rootConfig.ts",
519
+ "size": 343,
520
+ "origSize": 2140,
521
+ "renderedExports": [
522
+ "isServerDefault"
523
+ ],
524
+ "removedExports": [],
525
+ "dependents": [
526
+ "/src/unstable-core-do-not-import.ts",
527
+ "/src/unstable-core-do-not-import/initTRPC.ts"
528
+ ],
529
+ "percent": 0.37,
530
+ "reduction": 83.97
531
+ },
532
+ {
533
+ "id": "/src/adapters/express.ts",
534
+ "size": 339,
535
+ "origSize": 1184,
536
+ "renderedExports": [
537
+ "createExpressMiddleware"
538
+ ],
539
+ "removedExports": [],
540
+ "dependents": [],
541
+ "percent": 0.37,
542
+ "reduction": 71.37
543
+ },
544
+ {
545
+ "id": "/src/adapters/node-http/content-type/json/index.ts",
546
+ "size": 292,
547
+ "origSize": 450,
548
+ "renderedExports": [
549
+ "nodeHTTPJSONContentTypeHandler"
550
+ ],
551
+ "removedExports": [],
552
+ "dependents": [
553
+ "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
554
+ ],
555
+ "percent": 0.32,
556
+ "reduction": 35.11
557
+ },
558
+ {
559
+ "id": "/src/unstable-core-do-not-import/types.ts",
560
+ "size": 221,
561
+ "origSize": 4055,
562
+ "renderedExports": [
563
+ "ERROR_SYMBOL"
564
+ ],
565
+ "removedExports": [],
566
+ "dependents": [
567
+ "/src/unstable-core-do-not-import.ts"
568
+ ],
569
+ "percent": 0.24,
570
+ "reduction": 94.55
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
+ },
584
+ {
585
+ "id": "/src/adapters/node-http/internals/contentType.ts",
586
+ "size": 116,
587
+ "origSize": 871,
588
+ "renderedExports": [
589
+ "createNodeHTTPContentTypeHandler"
590
+ ],
591
+ "removedExports": [],
592
+ "dependents": [
593
+ "/src/adapters/node-http/content-type/form-data/index.ts",
594
+ "/src/adapters/node-http/content-type/json/index.ts"
595
+ ],
596
+ "percent": 0.13,
597
+ "reduction": 86.68
598
+ },
599
+ {
600
+ "id": "/src/unstable-core-do-not-import/procedure.ts",
601
+ "size": 75,
602
+ "origSize": 1956,
603
+ "renderedExports": [
604
+ "procedureTypes"
605
+ ],
606
+ "removedExports": [],
607
+ "dependents": [
608
+ "/src/unstable-core-do-not-import.ts",
609
+ "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts"
610
+ ],
611
+ "percent": 0.08,
612
+ "reduction": 96.17
613
+ },
614
+ {
615
+ "id": "/src/unstable-core-do-not-import/error/formatter.ts",
616
+ "size": 61,
617
+ "origSize": 984,
618
+ "renderedExports": [
619
+ "defaultFormatter"
620
+ ],
621
+ "removedExports": [],
622
+ "dependents": [
623
+ "/src/unstable-core-do-not-import.ts",
624
+ "/src/unstable-core-do-not-import/router.ts",
625
+ "/src/unstable-core-do-not-import/initTRPC.ts"
626
+ ],
627
+ "percent": 0.07,
628
+ "reduction": 93.8
629
+ },
630
+ {
631
+ "id": "/src/http.ts",
632
+ "size": 0,
633
+ "origSize": 37,
634
+ "renderedExports": [],
635
+ "removedExports": [],
636
+ "dependents": [],
637
+ "percent": 0,
638
+ "reduction": 100
639
+ },
640
+ {
641
+ "id": "/src/index.ts",
642
+ "size": 0,
643
+ "origSize": 32,
644
+ "renderedExports": [],
645
+ "removedExports": [],
646
+ "dependents": [],
647
+ "percent": 0,
648
+ "reduction": 100
649
+ },
650
+ {
651
+ "id": "/src/rpc.ts",
652
+ "size": 0,
653
+ "origSize": 36,
654
+ "renderedExports": [],
655
+ "removedExports": [],
656
+ "dependents": [],
657
+ "percent": 0,
658
+ "reduction": 100
659
+ },
660
+ {
661
+ "id": "/src/shared.ts",
662
+ "size": 0,
663
+ "origSize": 653,
664
+ "renderedExports": [],
665
+ "removedExports": [],
666
+ "dependents": [],
667
+ "percent": 0,
668
+ "reduction": 100
669
+ },
670
+ {
671
+ "id": "/src/unstable-core-do-not-import.ts",
672
+ "size": 0,
673
+ "origSize": 1552,
674
+ "renderedExports": [],
675
+ "removedExports": [],
676
+ "dependents": [],
677
+ "percent": 0,
678
+ "reduction": 100
679
+ },
680
+ {
681
+ "id": "/src/observable/index.ts",
682
+ "size": 0,
683
+ "origSize": 293,
684
+ "renderedExports": [],
685
+ "removedExports": [],
686
+ "dependents": [
687
+ "/src/adapters/ws.ts"
688
+ ],
689
+ "percent": 0,
690
+ "reduction": 100
691
+ },
692
+ {
693
+ "id": "/src/adapters/fastify/index.ts",
694
+ "size": 0,
695
+ "origSize": 78,
696
+ "renderedExports": [],
697
+ "removedExports": [],
698
+ "dependents": [],
699
+ "percent": 0,
700
+ "reduction": 100
701
+ },
702
+ {
703
+ "id": "/src/adapters/fetch/index.ts",
704
+ "size": 0,
705
+ "origSize": 64,
706
+ "renderedExports": [],
707
+ "removedExports": [],
708
+ "dependents": [],
709
+ "percent": 0,
710
+ "reduction": 100
711
+ },
712
+ {
713
+ "id": "/src/adapters/node-http/index.ts",
714
+ "size": 0,
715
+ "origSize": 67,
716
+ "renderedExports": [],
717
+ "removedExports": [],
718
+ "dependents": [
719
+ "/src/adapters/express.ts",
720
+ "/src/adapters/next.ts",
721
+ "/src/adapters/standalone.ts"
722
+ ],
723
+ "percent": 0,
724
+ "reduction": 100
725
+ }
726
+ ],
727
+ "moduleCount": 50
728
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-alpha-tmp-02-04-resolver-alt.279+1cf6fb600",
3
+ "version": "11.0.0-alpha-tmp-02-08-tmp.274+fc6e807b1",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -149,7 +149,7 @@
149
149
  "tsx": "^4.0.0",
150
150
  "typescript": "^5.3.3",
151
151
  "valibot": "^0.28.0",
152
- "vitest": "^0.32.0",
152
+ "vitest": "^1.2.2",
153
153
  "ws": "^8.0.0",
154
154
  "yup": "^1.0.0",
155
155
  "zod": "^3.0.0"
@@ -157,5 +157,5 @@
157
157
  "funding": [
158
158
  "https://trpc.io/sponsor"
159
159
  ],
160
- "gitHead": "1cf6fb6006d041a8d9102b1782d92190f4f34149"
160
+ "gitHead": "fc6e807b19d0b6fc726daa0a58ff5fcefcbef3d2"
161
161
  }
@@ -43,6 +43,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
43
43
  );
44
44
 
45
45
  let prefix = opts.prefix ?? '';
46
+ const websocketPrefix = prefix;
46
47
 
47
48
  // https://github.com/fastify/fastify-plugin/blob/fe079bef6557a83794bf437e14b9b9edb8a74104/plugin.js#L11
48
49
  // @ts-expect-error property 'default' does not exists on type ...
@@ -58,6 +59,7 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
58
59
  if (opts.useWSS) {
59
60
  applyWSSHandler<TRouter>({
60
61
  ...(opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>),
62
+ prefix: websocketPrefix,
61
63
  wss: fastify.websocketServer,
62
64
  });
63
65
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -66,15 +66,20 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = BaseHandlerOptions<
66
66
  }) & {
67
67
  wss: ws.WebSocketServer;
68
68
  process?: NodeJS.Process;
69
+ prefix?: string;
69
70
  };
70
71
 
71
72
  export function applyWSSHandler<TRouter extends AnyRouter>(
72
73
  opts: WSSHandlerOptions<TRouter>,
73
74
  ) {
74
- const { wss, createContext, router } = opts;
75
+ const { wss, createContext, router, prefix } = opts;
75
76
 
76
77
  const { transformer } = router._def._config;
77
78
  wss.on('connection', async (client, req) => {
79
+ if (prefix && !req.url?.startsWith(prefix)) {
80
+ return;
81
+ }
82
+
78
83
  const clientSubscriptions = new Map<number | string, Unsubscribable>();
79
84
 
80
85
  function respond(untransformedJSON: TRPCResponseMessage) {