Skip to content

Commit d1fa333

Browse files
committed
revert: "feat: ➕ use superjson instead of built-in json"
This reverts commit e2d1e84.
1 parent d7d7929 commit d1fa333

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"build": "rimraf dist && rimraf adapter && rimraf link && rimraf types && tsc -p tsconfig.build.json && shx mv dist/* . && rimraf dist"
1919
},
2020
"peerDependencies": {
21-
"@trpc/client": "^10.0.0-proxy-beta.18",
22-
"@trpc/server": "^10.0.0-proxy-beta.18"
21+
"@trpc/client": "10.0.0-proxy-beta.18",
22+
"@trpc/server": "10.0.0-proxy-beta.18"
2323
},
2424
"devDependencies": {
2525
"@trivago/prettier-plugin-sort-imports": "^3.3.0",

src/adapter/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import type { OnErrorFunction } from '@trpc/server/dist/internals/types';
99
import * as amqp from 'amqp-connection-manager';
1010
import type { ConsumeMessage } from 'amqplib';
11-
import { parse, stringify } from 'superjson';
1211

1312
import { getErrorFromUnknown } from './errors';
1413

@@ -42,7 +41,7 @@ export const createRMQHandler = <TRouter extends AnyRouter>(
4241
if (!correlationId || !replyTo) return;
4342
const res = await handleMessage(router, msg, onError);
4443
if (!res) return;
45-
void channel.sendToQueue(replyTo as string, Buffer.from(stringify({ trpc: res })), {
44+
void channel.sendToQueue(replyTo as string, Buffer.from(JSON.stringify({ trpc: res })), {
4645
correlationId: correlationId as string
4746
});
4847
});
@@ -60,7 +59,7 @@ async function handleMessage<TRouter extends AnyRouter>(
6059
const { transformer } = router._def._config;
6160

6261
try {
63-
const message: any = parse(msg.content.toString('utf-8'));
62+
const message = JSON.parse(msg.content.toString('utf-8'));
6463
if (!('trpc' in message)) return;
6564
const { trpc } = message;
6665
if (!('id' in trpc) || trpc.id === null || trpc.id === undefined) return;

src/link/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { observable } from '@trpc/server/observable';
44
import * as amqp from 'amqp-connection-manager';
55
import { randomUUID } from 'crypto';
66
import EventEmitter from 'events';
7-
import { parse, stringify } from 'superjson';
87

98
import type { TRPCRMQRequest, TRPCRMQResponse } from '../types';
109

@@ -32,7 +31,7 @@ export const rmqLink = <TRouter extends AnyRouter>(opts: TRPCRMQLinkOptions): TR
3231
if (!msg) return;
3332
responseEmitter.emit(
3433
msg.properties.correlationId as string,
35-
parse(msg.content.toString('utf-8'))
34+
JSON.parse(msg.content.toString('utf-8'))
3635
);
3736
},
3837
{ noAck: true }
@@ -44,7 +43,7 @@ export const rmqLink = <TRouter extends AnyRouter>(opts: TRPCRMQLinkOptions): TR
4443
new Promise<any>(resolve => {
4544
const correlationId = randomUUID();
4645
responseEmitter.once(correlationId, resolve);
47-
void channel.sendToQueue(queue, Buffer.from(stringify(message)), {
46+
void channel.sendToQueue(queue, Buffer.from(JSON.stringify(message)), {
4847
correlationId,
4948
replyTo: REPLY_QUEUE
5049
});

0 commit comments

Comments
 (0)