@trpc/server 11.0.0-rc.477 → 11.0.0-rc.480
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/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
- package/dist/adapters/fastify/fastifyTRPCPlugin.js +9 -2
- package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +10 -3
- package/dist/adapters/ws.d.ts +4 -0
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -0
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +58 -57
- package/package.json +2 -2
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +11 -5
- package/src/adapters/ws.ts +1 -1
|
@@ -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;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,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,
|
|
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;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,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,QAyC5B"}
|
|
@@ -36,12 +36,19 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
if (opts.useWSS) {
|
|
39
|
+
const trpcOptions = opts.trpcOptions;
|
|
39
40
|
const onConnection = ws.getWSConnectionHandler({
|
|
40
|
-
...
|
|
41
|
+
...trpcOptions
|
|
41
42
|
});
|
|
42
43
|
fastify.get(prefix ?? '/', {
|
|
43
44
|
websocket: true
|
|
44
|
-
}, (socket, req)=>
|
|
45
|
+
}, async (socket, req)=>{
|
|
46
|
+
await onConnection(socket, req.raw);
|
|
47
|
+
if (trpcOptions?.keepAlive?.enabled) {
|
|
48
|
+
const { pingMs , pongWaitMs } = trpcOptions.keepAlive;
|
|
49
|
+
ws.handleKeepAlive(socket, pingMs, pongWaitMs);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
45
52
|
}
|
|
46
53
|
done();
|
|
47
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getWSConnectionHandler } from '../ws.mjs';
|
|
1
|
+
import { getWSConnectionHandler, handleKeepAlive } from '../ws.mjs';
|
|
2
2
|
import { fastifyRequestHandler } from './fastifyRequestHandler.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -34,12 +34,19 @@ function fastifyTRPCPlugin(fastify, opts, done) {
|
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
36
|
if (opts.useWSS) {
|
|
37
|
+
const trpcOptions = opts.trpcOptions;
|
|
37
38
|
const onConnection = getWSConnectionHandler({
|
|
38
|
-
...
|
|
39
|
+
...trpcOptions
|
|
39
40
|
});
|
|
40
41
|
fastify.get(prefix ?? '/', {
|
|
41
42
|
websocket: true
|
|
42
|
-
}, (socket, req)=>
|
|
43
|
+
}, async (socket, req)=>{
|
|
44
|
+
await onConnection(socket, req.raw);
|
|
45
|
+
if (trpcOptions?.keepAlive?.enabled) {
|
|
46
|
+
const { pingMs , pongWaitMs } = trpcOptions.keepAlive;
|
|
47
|
+
handleKeepAlive(socket, pingMs, pongWaitMs);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
43
50
|
}
|
|
44
51
|
done();
|
|
45
52
|
}
|
package/dist/adapters/ws.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = WSConnectionHandlerOp
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
export declare function getWSConnectionHandler<TRouter extends AnyRouter>(opts: WSConnectionHandlerOptions<TRouter>): (client: ws.WebSocket, req: IncomingMessage) => Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Handle WebSocket keep-alive messages
|
|
43
|
+
*/
|
|
44
|
+
export declare function handleKeepAlive(client: ws.WebSocket, pingMs?: number, pongWaitMs?: number): void;
|
|
41
45
|
export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
|
|
42
46
|
broadcastReconnectNotification: () => void;
|
|
43
47
|
};
|
|
@@ -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;AActE,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,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,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;CACH,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,YAKnB,EAAE,CAAC,SAAS,OAAO,eAAe,mBAuWzD;
|
|
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;AActE,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,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,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;CACH,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,YAKnB,EAAE,CAAC,SAAS,OAAO,eAAe,mBAuWzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,EAAE,CAAC,SAAS,EACpB,MAAM,SAAQ,EACd,UAAU,SAAO,QAuBlB;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA+BjC"}
|
package/dist/adapters/ws.js
CHANGED
package/dist/adapters/ws.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 26.
|
|
2
|
+
"bundleSize": 135062,
|
|
3
|
+
"bundleOrigSize": 183958,
|
|
4
|
+
"bundleReduction": 26.58,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/unstable-core-do-not-import.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 13.
|
|
17
|
+
"percent": 13.15,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -31,22 +31,23 @@
|
|
|
31
31
|
"/src/unstable-core-do-not-import.ts",
|
|
32
32
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 12.
|
|
34
|
+
"percent": 12.88,
|
|
35
35
|
"reduction": 4.62
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/adapters/ws.ts",
|
|
39
39
|
"size": 15730,
|
|
40
|
-
"origSize":
|
|
40
|
+
"origSize": 14672,
|
|
41
41
|
"renderedExports": [
|
|
42
42
|
"getWSConnectionHandler",
|
|
43
|
+
"handleKeepAlive",
|
|
43
44
|
"applyWSSHandler"
|
|
44
45
|
],
|
|
45
46
|
"removedExports": [],
|
|
46
47
|
"dependents": [
|
|
47
48
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
49
|
],
|
|
49
|
-
"percent": 11.
|
|
50
|
+
"percent": 11.65,
|
|
50
51
|
"reduction": 0
|
|
51
52
|
},
|
|
52
53
|
{
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"/src/unstable-core-do-not-import.ts",
|
|
62
63
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
63
64
|
],
|
|
64
|
-
"percent": 5.
|
|
65
|
+
"percent": 5.69,
|
|
65
66
|
"reduction": 0
|
|
66
67
|
},
|
|
67
68
|
{
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
"/src/unstable-core-do-not-import.ts",
|
|
80
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
81
82
|
],
|
|
82
|
-
"percent": 4.
|
|
83
|
+
"percent": 4.72,
|
|
83
84
|
"reduction": 39.77
|
|
84
85
|
},
|
|
85
86
|
{
|
|
@@ -94,7 +95,7 @@
|
|
|
94
95
|
"/src/unstable-core-do-not-import.ts",
|
|
95
96
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
96
97
|
],
|
|
97
|
-
"percent": 4.
|
|
98
|
+
"percent": 4.68,
|
|
98
99
|
"reduction": 60.09
|
|
99
100
|
},
|
|
100
101
|
{
|
|
@@ -125,7 +126,7 @@
|
|
|
125
126
|
"dependents": [
|
|
126
127
|
"/src/adapters/aws-lambda/index.ts"
|
|
127
128
|
],
|
|
128
|
-
"percent": 4.
|
|
129
|
+
"percent": 4.01,
|
|
129
130
|
"reduction": 11.38
|
|
130
131
|
},
|
|
131
132
|
{
|
|
@@ -159,7 +160,7 @@
|
|
|
159
160
|
"dependents": [
|
|
160
161
|
"/src/adapters/next-app-dir.ts"
|
|
161
162
|
],
|
|
162
|
-
"percent": 2.
|
|
163
|
+
"percent": 2.32,
|
|
163
164
|
"reduction": 23.5
|
|
164
165
|
},
|
|
165
166
|
{
|
|
@@ -191,11 +192,11 @@
|
|
|
191
192
|
"removedExports": [],
|
|
192
193
|
"dependents": [
|
|
193
194
|
"/src/unstable-core-do-not-import.ts",
|
|
195
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
194
196
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
195
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
196
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
197
|
+
"/src/unstable-core-do-not-import/router.ts"
|
|
197
198
|
],
|
|
198
|
-
"percent": 2.
|
|
199
|
+
"percent": 2.03,
|
|
199
200
|
"reduction": 45.94
|
|
200
201
|
},
|
|
201
202
|
{
|
|
@@ -209,7 +210,7 @@
|
|
|
209
210
|
"dependents": [
|
|
210
211
|
"/src/adapters/node-http/index.ts"
|
|
211
212
|
],
|
|
212
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.02,
|
|
213
214
|
"reduction": 6.79
|
|
214
215
|
},
|
|
215
216
|
{
|
|
@@ -223,7 +224,7 @@
|
|
|
223
224
|
"dependents": [
|
|
224
225
|
"/src/unstable-core-do-not-import.ts"
|
|
225
226
|
],
|
|
226
|
-
"percent": 2
|
|
227
|
+
"percent": 2,
|
|
227
228
|
"reduction": 40.91
|
|
228
229
|
},
|
|
229
230
|
{
|
|
@@ -259,7 +260,7 @@
|
|
|
259
260
|
"/src/unstable-core-do-not-import.ts",
|
|
260
261
|
"/src/unstable-core-do-not-import/router.ts"
|
|
261
262
|
],
|
|
262
|
-
"percent": 1.
|
|
263
|
+
"percent": 1.72,
|
|
263
264
|
"reduction": 0
|
|
264
265
|
},
|
|
265
266
|
{
|
|
@@ -288,7 +289,7 @@
|
|
|
288
289
|
"/src/adapters/node-http/index.ts",
|
|
289
290
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
290
291
|
],
|
|
291
|
-
"percent": 1.
|
|
292
|
+
"percent": 1.62,
|
|
292
293
|
"reduction": 13.79
|
|
293
294
|
},
|
|
294
295
|
{
|
|
@@ -305,6 +306,20 @@
|
|
|
305
306
|
"percent": 1.52,
|
|
306
307
|
"reduction": 5.79
|
|
307
308
|
},
|
|
309
|
+
{
|
|
310
|
+
"id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
|
|
311
|
+
"size": 1779,
|
|
312
|
+
"origSize": 2537,
|
|
313
|
+
"renderedExports": [
|
|
314
|
+
"fastifyTRPCPlugin"
|
|
315
|
+
],
|
|
316
|
+
"removedExports": [],
|
|
317
|
+
"dependents": [
|
|
318
|
+
"/src/adapters/fastify/index.ts"
|
|
319
|
+
],
|
|
320
|
+
"percent": 1.32,
|
|
321
|
+
"reduction": 29.88
|
|
322
|
+
},
|
|
308
323
|
{
|
|
309
324
|
"id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
310
325
|
"size": 1733,
|
|
@@ -317,16 +332,16 @@
|
|
|
317
332
|
"removedExports": [],
|
|
318
333
|
"dependents": [
|
|
319
334
|
"/src/unstable-core-do-not-import.ts",
|
|
320
|
-
"/src/unstable-core-do-not-import/middleware.ts",
|
|
321
|
-
"/src/unstable-core-do-not-import/router.ts",
|
|
322
335
|
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
323
336
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
337
|
+
"/src/unstable-core-do-not-import/middleware.ts",
|
|
338
|
+
"/src/unstable-core-do-not-import/router.ts",
|
|
324
339
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
325
340
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
326
341
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
327
342
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
328
343
|
],
|
|
329
|
-
"percent": 1.
|
|
344
|
+
"percent": 1.28,
|
|
330
345
|
"reduction": 19.47
|
|
331
346
|
},
|
|
332
347
|
{
|
|
@@ -351,7 +366,7 @@
|
|
|
351
366
|
],
|
|
352
367
|
"removedExports": [],
|
|
353
368
|
"dependents": [],
|
|
354
|
-
"percent": 1.
|
|
369
|
+
"percent": 1.19,
|
|
355
370
|
"reduction": 27.47
|
|
356
371
|
},
|
|
357
372
|
{
|
|
@@ -366,20 +381,6 @@
|
|
|
366
381
|
"percent": 1.14,
|
|
367
382
|
"reduction": 26.94
|
|
368
383
|
},
|
|
369
|
-
{
|
|
370
|
-
"id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
|
|
371
|
-
"size": 1500,
|
|
372
|
-
"origSize": 2297,
|
|
373
|
-
"renderedExports": [
|
|
374
|
-
"fastifyTRPCPlugin"
|
|
375
|
-
],
|
|
376
|
-
"removedExports": [],
|
|
377
|
-
"dependents": [
|
|
378
|
-
"/src/adapters/fastify/index.ts"
|
|
379
|
-
],
|
|
380
|
-
"percent": 1.11,
|
|
381
|
-
"reduction": 34.7
|
|
382
|
-
},
|
|
383
384
|
{
|
|
384
385
|
"id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
385
386
|
"size": 1365,
|
|
@@ -391,8 +392,8 @@
|
|
|
391
392
|
"removedExports": [],
|
|
392
393
|
"dependents": [
|
|
393
394
|
"/src/unstable-core-do-not-import.ts",
|
|
394
|
-
"/src/unstable-core-do-not-import/
|
|
395
|
-
"/src/unstable-core-do-not-import/
|
|
395
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
396
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
396
397
|
],
|
|
397
398
|
"percent": 1.01,
|
|
398
399
|
"reduction": 17.52
|
|
@@ -413,13 +414,13 @@
|
|
|
413
414
|
"removedExports": [],
|
|
414
415
|
"dependents": [
|
|
415
416
|
"/src/unstable-core-do-not-import.ts",
|
|
417
|
+
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
418
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
419
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
416
420
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
417
421
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
418
422
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
419
423
|
"/src/unstable-core-do-not-import/router.ts",
|
|
420
|
-
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
421
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
422
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
423
424
|
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
424
425
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
425
426
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -471,7 +472,7 @@
|
|
|
471
472
|
"dependents": [
|
|
472
473
|
"/src/unstable-core-do-not-import.ts"
|
|
473
474
|
],
|
|
474
|
-
"percent": 0.
|
|
475
|
+
"percent": 0.78,
|
|
475
476
|
"reduction": 0
|
|
476
477
|
},
|
|
477
478
|
{
|
|
@@ -724,16 +725,6 @@
|
|
|
724
725
|
"percent": 0.05,
|
|
725
726
|
"reduction": 93.8
|
|
726
727
|
},
|
|
727
|
-
{
|
|
728
|
-
"id": "/src/index.ts",
|
|
729
|
-
"size": 0,
|
|
730
|
-
"origSize": 32,
|
|
731
|
-
"renderedExports": [],
|
|
732
|
-
"removedExports": [],
|
|
733
|
-
"dependents": [],
|
|
734
|
-
"percent": 0,
|
|
735
|
-
"reduction": 100
|
|
736
|
-
},
|
|
737
728
|
{
|
|
738
729
|
"id": "/src/http.ts",
|
|
739
730
|
"size": 0,
|
|
@@ -747,9 +738,9 @@
|
|
|
747
738
|
"reduction": 100
|
|
748
739
|
},
|
|
749
740
|
{
|
|
750
|
-
"id": "/src/
|
|
741
|
+
"id": "/src/index.ts",
|
|
751
742
|
"size": 0,
|
|
752
|
-
"origSize":
|
|
743
|
+
"origSize": 32,
|
|
753
744
|
"renderedExports": [],
|
|
754
745
|
"removedExports": [],
|
|
755
746
|
"dependents": [],
|
|
@@ -757,9 +748,9 @@
|
|
|
757
748
|
"reduction": 100
|
|
758
749
|
},
|
|
759
750
|
{
|
|
760
|
-
"id": "/src/
|
|
751
|
+
"id": "/src/rpc.ts",
|
|
761
752
|
"size": 0,
|
|
762
|
-
"origSize":
|
|
753
|
+
"origSize": 36,
|
|
763
754
|
"renderedExports": [],
|
|
764
755
|
"removedExports": [],
|
|
765
756
|
"dependents": [],
|
|
@@ -779,6 +770,16 @@
|
|
|
779
770
|
"percent": 0,
|
|
780
771
|
"reduction": 100
|
|
781
772
|
},
|
|
773
|
+
{
|
|
774
|
+
"id": "/src/shared.ts",
|
|
775
|
+
"size": 0,
|
|
776
|
+
"origSize": 653,
|
|
777
|
+
"renderedExports": [],
|
|
778
|
+
"removedExports": [],
|
|
779
|
+
"dependents": [],
|
|
780
|
+
"percent": 0,
|
|
781
|
+
"reduction": 100
|
|
782
|
+
},
|
|
782
783
|
{
|
|
783
784
|
"id": "/src/adapters/next-app-dir.ts",
|
|
784
785
|
"size": 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.480+6dc84d9eb",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "6dc84d9ebef60539d4e835c17aff9ee22cbf204b"
|
|
153
153
|
}
|
|
@@ -14,7 +14,7 @@ import type { AnyRouter } from '../../@trpc/server';
|
|
|
14
14
|
// @trpc/server/http
|
|
15
15
|
import type { NodeHTTPCreateContextFnOptions } from '../node-http';
|
|
16
16
|
// @trpc/server/ws
|
|
17
|
-
import { getWSConnectionHandler, type WSSHandlerOptions } from '../ws';
|
|
17
|
+
import { getWSConnectionHandler, handleKeepAlive, type WSSHandlerOptions } from '../ws';
|
|
18
18
|
import type { FastifyHandlerOptions } from './fastifyRequestHandler';
|
|
19
19
|
import { fastifyRequestHandler } from './fastifyRequestHandler';
|
|
20
20
|
|
|
@@ -57,13 +57,19 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
if (opts.useWSS) {
|
|
60
|
+
const trpcOptions = opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>;
|
|
61
|
+
|
|
60
62
|
const onConnection = getWSConnectionHandler<TRouter>({
|
|
61
|
-
...
|
|
63
|
+
...trpcOptions,
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
fastify.get(prefix ?? '/', { websocket: true }, (socket, req) =>
|
|
65
|
-
onConnection(socket, req.raw)
|
|
66
|
-
|
|
66
|
+
fastify.get(prefix ?? '/', { websocket: true }, async (socket, req) => {
|
|
67
|
+
await onConnection(socket, req.raw);
|
|
68
|
+
if (trpcOptions?.keepAlive?.enabled) {
|
|
69
|
+
const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
|
|
70
|
+
handleKeepAlive(socket, pingMs, pongWaitMs);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
done();
|
package/src/adapters/ws.ts
CHANGED
|
@@ -461,7 +461,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
461
461
|
/**
|
|
462
462
|
* Handle WebSocket keep-alive messages
|
|
463
463
|
*/
|
|
464
|
-
function handleKeepAlive(
|
|
464
|
+
export function handleKeepAlive(
|
|
465
465
|
client: ws.WebSocket,
|
|
466
466
|
pingMs = 30000,
|
|
467
467
|
pongWaitMs = 5000,
|