trpc-uwebsockets 10.44.0 → 10.46.0
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/README.md +10 -4
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/utils.ts +7 -3
- package/test/index.spec.ts +163 -160
- package/types/utils.d.ts +1 -1
package/README.md
CHANGED
|
@@ -4,10 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
# Installation
|
|
6
6
|
|
|
7
|
+
Version 10
|
|
8
|
+
|
|
7
9
|
```bash
|
|
8
10
|
npm install trpc-uwebsockets
|
|
9
11
|
```
|
|
10
12
|
|
|
13
|
+
Version 11 beta
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install trpc-uwebsockets@beta
|
|
17
|
+
```
|
|
18
|
+
|
|
11
19
|
# Usage
|
|
12
20
|
|
|
13
21
|
Import needed packages
|
|
@@ -65,10 +73,8 @@ const app = App();
|
|
|
65
73
|
|
|
66
74
|
/* handle CORS as needed */
|
|
67
75
|
app.options('/*', (res) => {
|
|
68
|
-
res.
|
|
69
|
-
|
|
70
|
-
res.endWithoutBody();
|
|
71
|
-
});
|
|
76
|
+
res.writeHeader('Access-Control-Allow-Origin', allowOrigin);
|
|
77
|
+
res.endWithoutBody();
|
|
72
78
|
});
|
|
73
79
|
|
|
74
80
|
createUWebSocketsHandler(app, '/trpc', {
|
package/dist/utils.js
CHANGED
|
@@ -24,7 +24,7 @@ function getPostBody(method, res, maxBodySize) {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
const chunk = Buffer.from(ab);
|
|
27
|
-
if (maxBodySize && buffer.length >= maxBodySize) {
|
|
27
|
+
if (maxBodySize && buffer && buffer.length >= maxBodySize) {
|
|
28
28
|
resolve({
|
|
29
29
|
ok: false,
|
|
30
30
|
error: new server_1.TRPCError({ code: 'PAYLOAD_TOO_LARGE' }),
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AAGzC,SAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,yCAAyC;AAGzC,SAAgB,WAAW,CACzB,MAAsB,EACtB,GAAiB,EACjB,WAAoB;IAEpB,OAAO,IAAI,OAAO,CAGhB,CAAC,OAAO,EAAE,EAAE;QACZ,IAAI,MAAM,IAAI,KAAK,EAAE;YACnB,yBAAyB;YACzB,OAAO,CAAC;gBACN,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,MAA0B,CAAC;QAE/B,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE;YACxB,+CAA+C;YAC/C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,EAAE;gBAClC,OAAO,CAAC;oBACN,EAAE,EAAE,IAAI;oBACR,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;oBAChC,YAAY,EAAE,KAAK;iBACpB,CAAC,CAAC;gBACH,OAAO;aACR;YAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAE9B,IAAI,WAAW,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,WAAW,EAAE;gBACzD,OAAO,CAAC;oBACN,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;iBACpD,CAAC,CAAC;aACJ;YACD,IAAI,MAAM;gBACR,iBAAiB;gBACjB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;;gBACrC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAErC,IAAI,MAAM,EAAE;gBACV,OAAO,CAAC;oBACN,EAAE,EAAE,IAAI;oBACR,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE;oBACvB,YAAY,EAAE,KAAK;iBACpB,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;YACjB,OAAO,CAAC;gBACN,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,IAAI,kBAAS,CAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;aACxD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA5DD,kCA4DC;AAED,SAAgB,yBAAyB,CACvC,MAAc,EACd,GAAgB;IAEhB,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,WAAW,EAAoB,CAAC;IAC/D,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAElD,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,MAAM;QACN,KAAK;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAnBD,8DAmBC"}
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -3,7 +3,11 @@ import { HttpRequest, HttpResponse } from 'uWebSockets.js';
|
|
|
3
3
|
import { TRPCError } from '@trpc/server';
|
|
4
4
|
import { WrappedHTTPRequest } from './types';
|
|
5
5
|
|
|
6
|
-
export function getPostBody(
|
|
6
|
+
export function getPostBody(
|
|
7
|
+
method: 'GET' | 'POST',
|
|
8
|
+
res: HttpResponse,
|
|
9
|
+
maxBodySize?: number
|
|
10
|
+
) {
|
|
7
11
|
return new Promise<
|
|
8
12
|
| { ok: true; data: unknown; preprocessed: boolean }
|
|
9
13
|
| { ok: false; error: TRPCError }
|
|
@@ -17,7 +21,7 @@ export function getPostBody(method, res: HttpResponse, maxBodySize?: number) {
|
|
|
17
21
|
});
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
let buffer: Buffer;
|
|
24
|
+
let buffer: Buffer | undefined;
|
|
21
25
|
|
|
22
26
|
res.onData((ab, isLast) => {
|
|
23
27
|
//resolve right away if there is only one chunk
|
|
@@ -32,7 +36,7 @@ export function getPostBody(method, res: HttpResponse, maxBodySize?: number) {
|
|
|
32
36
|
|
|
33
37
|
const chunk = Buffer.from(ab);
|
|
34
38
|
|
|
35
|
-
if (maxBodySize && buffer.length >= maxBodySize) {
|
|
39
|
+
if (maxBodySize && buffer && buffer.length >= maxBodySize) {
|
|
36
40
|
resolve({
|
|
37
41
|
ok: false,
|
|
38
42
|
error: new TRPCError({ code: 'PAYLOAD_TOO_LARGE' }),
|
package/test/index.spec.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
vi,
|
|
3
|
-
beforeEach,
|
|
4
|
-
afterEach,
|
|
5
|
-
test,
|
|
6
|
-
expect,
|
|
7
|
-
expectTypeOf,
|
|
8
|
-
describe,
|
|
9
|
-
} from 'vitest';
|
|
1
|
+
import { vi, beforeEach, afterEach, test, expect, expectTypeOf } from 'vitest';
|
|
10
2
|
// idk how to use that
|
|
11
3
|
// import { waitFor } from '@testing-library/dom';
|
|
12
4
|
|
|
@@ -153,6 +145,7 @@ async function startServer() {
|
|
|
153
145
|
},
|
|
154
146
|
};
|
|
155
147
|
},
|
|
148
|
+
maxBodySize: 10000,
|
|
156
149
|
|
|
157
150
|
router,
|
|
158
151
|
createContext: makeContext(),
|
|
@@ -302,37 +295,34 @@ const linkSpy: TRPCLink<AppRouter> = () => {
|
|
|
302
295
|
};
|
|
303
296
|
};
|
|
304
297
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
).toMatchInlineSnapshot(`
|
|
298
|
+
test('query simple success and error handling', async () => {
|
|
299
|
+
// t.client.runtime.headers = ()
|
|
300
|
+
const { client } = makeClient({});
|
|
301
|
+
|
|
302
|
+
// client.
|
|
303
|
+
expect(
|
|
304
|
+
await client.hello.query({
|
|
305
|
+
who: 'test',
|
|
306
|
+
})
|
|
307
|
+
).toMatchInlineSnapshot(`
|
|
316
308
|
{
|
|
317
309
|
"text": "hello test",
|
|
318
310
|
}
|
|
319
311
|
`);
|
|
320
312
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
);
|
|
324
|
-
});
|
|
313
|
+
await expect(client.error.query()).rejects.toThrowError('error as expected');
|
|
314
|
+
});
|
|
325
315
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
316
|
+
test('mutation and reading headers', async () => {
|
|
317
|
+
const { client } = makeClient({
|
|
318
|
+
authorization: 'meow',
|
|
319
|
+
});
|
|
330
320
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
321
|
+
expect(
|
|
322
|
+
await client.test.mutate({
|
|
323
|
+
value: 'lala',
|
|
324
|
+
})
|
|
325
|
+
).toMatchInlineSnapshot(`
|
|
336
326
|
{
|
|
337
327
|
"originalValue": "lala",
|
|
338
328
|
"user": {
|
|
@@ -340,99 +330,99 @@ describe('main tests', () => {
|
|
|
340
330
|
},
|
|
341
331
|
}
|
|
342
332
|
`);
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
test('manually sets status and headers', async () => {
|
|
346
|
-
const fetcher = await fetch(
|
|
347
|
-
`http://localhost:${testPort}/trpc/manualRes?input=${encodeURI('{}')}`
|
|
348
|
-
);
|
|
349
|
-
const body = await fetcher.json();
|
|
350
|
-
expect(fetcher.status).toEqual(400);
|
|
351
|
-
expect(body.result.data).toEqual('status 400');
|
|
333
|
+
});
|
|
352
334
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
335
|
+
test('manually sets status and headers', async () => {
|
|
336
|
+
const fetcher = await fetch(
|
|
337
|
+
`http://localhost:${testPort}/trpc/manualRes?input=${encodeURI('{}')}`
|
|
338
|
+
);
|
|
339
|
+
const body = await fetcher.json();
|
|
340
|
+
expect(fetcher.status).toEqual(400);
|
|
341
|
+
expect(body.result.data).toEqual('status 400');
|
|
356
342
|
|
|
357
|
-
//
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const { client } = makeClient({});
|
|
343
|
+
expect(fetcher.headers.get('Access-Control-Allow-Origin')).toEqual('*'); // from the meta
|
|
344
|
+
expect(fetcher.headers.get('manual')).toEqual('header'); //from the result
|
|
345
|
+
});
|
|
361
346
|
|
|
362
|
-
|
|
347
|
+
// this needs to be tested
|
|
348
|
+
test('aborting requests works', async () => {
|
|
349
|
+
const ac = new AbortController();
|
|
350
|
+
const { client } = makeClient({});
|
|
363
351
|
|
|
364
|
-
|
|
365
|
-
ac.abort();
|
|
366
|
-
});
|
|
352
|
+
expect.assertions(1);
|
|
367
353
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
{
|
|
371
|
-
value: 'haha',
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
signal: ac.signal as any,
|
|
375
|
-
}
|
|
376
|
-
);
|
|
377
|
-
} catch (error) {
|
|
378
|
-
expect(error.name).toBe('TRPCClientError');
|
|
379
|
-
}
|
|
354
|
+
setTimeout(() => {
|
|
355
|
+
ac.abort();
|
|
380
356
|
});
|
|
381
357
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
358
|
+
try {
|
|
359
|
+
await client.test.mutate(
|
|
360
|
+
{
|
|
361
|
+
value: 'haha',
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
signal: ac.signal as any,
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
expect(error.name).toBe('TRPCClientError');
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// FIXME no idea how to make it non-flaky
|
|
373
|
+
const sleep = (ms: number) => new Promise((res) => setTimeout(res, ms));
|
|
374
|
+
|
|
375
|
+
// Source: https://github.com/trpc/trpc/blob/main/packages/tests/server/adapters/fastify.test.ts
|
|
376
|
+
test(
|
|
377
|
+
'ugly subscription tests',
|
|
378
|
+
async () => {
|
|
379
|
+
ee.once('subscription:created', () => {
|
|
380
|
+
setTimeout(() => {
|
|
381
|
+
ee.emit('server:msg', {
|
|
382
|
+
id: '1',
|
|
383
|
+
});
|
|
384
|
+
ee.emit('server:msg', {
|
|
385
|
+
id: '2',
|
|
397
386
|
});
|
|
398
387
|
});
|
|
388
|
+
});
|
|
399
389
|
|
|
400
|
-
|
|
390
|
+
const { client, closeWs } = makeClientWithWs({});
|
|
401
391
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
392
|
+
const onStartedMock = vi.fn();
|
|
393
|
+
const onDataMock = vi.fn();
|
|
394
|
+
const sub = client.onMessage.subscribe('onMessage', {
|
|
395
|
+
onStarted: onStartedMock,
|
|
396
|
+
onData(data) {
|
|
397
|
+
expectTypeOf(data).not.toBeAny();
|
|
398
|
+
expectTypeOf(data).toMatchTypeOf<Message>();
|
|
399
|
+
onDataMock(data);
|
|
400
|
+
},
|
|
401
|
+
});
|
|
412
402
|
|
|
413
|
-
|
|
403
|
+
// onStartedMock.
|
|
414
404
|
|
|
415
|
-
|
|
405
|
+
// expect(onStartedMock).toh
|
|
416
406
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
407
|
+
await sleep(300); // FIXME how to use waitFor instead?
|
|
408
|
+
expect(onStartedMock).toHaveBeenCalledTimes(1);
|
|
409
|
+
expect(onDataMock).toHaveBeenCalledTimes(2);
|
|
410
|
+
// await waitFor(() => {
|
|
411
|
+
// expect(onStartedMock).toHaveBeenCalledTimes(1);
|
|
412
|
+
// expect(onDataMock).toHaveBeenCalledTimes(2);
|
|
413
|
+
// });
|
|
424
414
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
415
|
+
ee.emit('server:msg', {
|
|
416
|
+
id: '3',
|
|
417
|
+
});
|
|
418
|
+
await sleep(500);
|
|
419
|
+
expect(onDataMock).toHaveBeenCalledTimes(3);
|
|
430
420
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
421
|
+
// await waitFor(() => {
|
|
422
|
+
// expect(onDataMock).toHaveBeenCalledTimes(3);
|
|
423
|
+
// });
|
|
434
424
|
|
|
435
|
-
|
|
425
|
+
expect(onDataMock.mock.calls).toMatchInlineSnapshot(`
|
|
436
426
|
[
|
|
437
427
|
[
|
|
438
428
|
{
|
|
@@ -452,64 +442,77 @@ describe('main tests', () => {
|
|
|
452
442
|
]
|
|
453
443
|
`);
|
|
454
444
|
|
|
455
|
-
|
|
445
|
+
sub.unsubscribe();
|
|
446
|
+
|
|
447
|
+
await sleep(500);
|
|
448
|
+
|
|
449
|
+
expect(ee.listenerCount('server:msg')).toBe(0);
|
|
450
|
+
expect(ee.listenerCount('server:error')).toBe(0);
|
|
451
|
+
|
|
452
|
+
await closeWs();
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
timeout: 10000,
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
test(
|
|
460
|
+
'subscription failed context',
|
|
461
|
+
async () => {
|
|
462
|
+
expect.assertions(2);
|
|
463
|
+
// const host = `localhost:${testPort}/trpc?user=user1`; // weClient can inject values via query string
|
|
464
|
+
const host = `localhost:${testPort}/trpc?user=user1&fail=yess`; // weClient can inject values via query string
|
|
465
|
+
const wsClient = createWSClient({
|
|
466
|
+
url: `ws://${host}`,
|
|
467
|
+
WebSocket,
|
|
468
|
+
retryDelayMs: (i) => {
|
|
469
|
+
console.log('retrying connection in subscription only', i);
|
|
470
|
+
return 200;
|
|
471
|
+
},
|
|
472
|
+
});
|
|
456
473
|
|
|
457
|
-
|
|
474
|
+
const client = createTRPCProxyClient<AppRouter>({
|
|
475
|
+
links: [wsLink({ client: wsClient })],
|
|
476
|
+
});
|
|
458
477
|
|
|
459
|
-
|
|
460
|
-
|
|
478
|
+
client.onMessage.subscribe('lala', {
|
|
479
|
+
onError(err) {
|
|
480
|
+
// expect this error here?
|
|
481
|
+
expect(err).toBeInstanceOf(TRPCClientError);
|
|
482
|
+
expect(err.message).toBe('failing as expected');
|
|
483
|
+
},
|
|
484
|
+
});
|
|
461
485
|
|
|
462
|
-
|
|
463
|
-
|
|
486
|
+
await sleep(100);
|
|
487
|
+
wsClient.close();
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
timeout: 3000,
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
test('options still passthrough (cors)', async () => {
|
|
495
|
+
const res = await fetch(
|
|
496
|
+
`http://localhost:${testPort}/trpc/hello?input=${encodeURI('{}')}`,
|
|
464
497
|
{
|
|
465
|
-
|
|
498
|
+
method: 'OPTIONS',
|
|
466
499
|
}
|
|
467
500
|
);
|
|
468
501
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
expect.assertions(2);
|
|
473
|
-
// const host = `localhost:${testPort}/trpc?user=user1`; // weClient can inject values via query string
|
|
474
|
-
const host = `localhost:${testPort}/trpc?user=user1&fail=yess`; // weClient can inject values via query string
|
|
475
|
-
const wsClient = createWSClient({
|
|
476
|
-
url: `ws://${host}`,
|
|
477
|
-
WebSocket,
|
|
478
|
-
retryDelayMs: (i) => {
|
|
479
|
-
console.log('retrying connection in subscription only', i);
|
|
480
|
-
return 200;
|
|
481
|
-
},
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
const client = createTRPCProxyClient<AppRouter>({
|
|
485
|
-
links: [wsLink({ client: wsClient })],
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
client.onMessage.subscribe('lala', {
|
|
489
|
-
onError(err) {
|
|
490
|
-
// expect this error here?
|
|
491
|
-
expect(err).toBeInstanceOf(TRPCClientError);
|
|
492
|
-
expect(err.message).toBe('failing as expected');
|
|
493
|
-
},
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
await sleep(100);
|
|
497
|
-
wsClient.close();
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
timeout: 3000,
|
|
501
|
-
}
|
|
502
|
-
);
|
|
502
|
+
expect(res.status).toBe(200);
|
|
503
|
+
expect(res.headers.get('Access-Control-Allow-Origin')).toBe('*');
|
|
504
|
+
});
|
|
503
505
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
{
|
|
508
|
-
method: 'OPTIONS',
|
|
509
|
-
}
|
|
510
|
-
);
|
|
506
|
+
test('large request body handling', async () => {
|
|
507
|
+
const { client } = makeClient({});
|
|
508
|
+
expect.assertions(2);
|
|
511
509
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
510
|
+
try {
|
|
511
|
+
await client.test.mutate({
|
|
512
|
+
value: '0'.repeat(200000),
|
|
513
|
+
});
|
|
514
|
+
} catch (error) {
|
|
515
|
+
expect(error.name).toBe('TRPCClientError');
|
|
516
|
+
expect(error.data.code).toBe('PAYLOAD_TOO_LARGE');
|
|
517
|
+
}
|
|
515
518
|
});
|
package/types/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpRequest, HttpResponse } from 'uWebSockets.js';
|
|
2
2
|
import { TRPCError } from '@trpc/server';
|
|
3
3
|
import { WrappedHTTPRequest } from './types';
|
|
4
|
-
export declare function getPostBody(method:
|
|
4
|
+
export declare function getPostBody(method: 'GET' | 'POST', res: HttpResponse, maxBodySize?: number): Promise<{
|
|
5
5
|
ok: true;
|
|
6
6
|
data: unknown;
|
|
7
7
|
preprocessed: boolean;
|