Skip to content

Commit a0832d0

Browse files
committed
feat: allow querying transaction status via query param
1 parent 21f1454 commit a0832d0

File tree

3 files changed

+0
-218
lines changed

3 files changed

+0
-218
lines changed

src/server/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { withOpenApi } from "./middleware/open-api";
1818
import { withPrometheus } from "./middleware/prometheus";
1919
import { withRateLimit } from "./middleware/rate-limit";
2020
import { withSecurityHeaders } from "./middleware/security-headers";
21-
import { withWebSocket } from "./middleware/websocket";
2221
import { withRoutes } from "./routes";
2322
import { writeOpenApiToFile } from "./utils/openapi";
2423

@@ -81,7 +80,6 @@ export const initServer = async () => {
8180
withPrometheus(server);
8281

8382
// Register routes
84-
await withWebSocket(server);
8583
await withAuth(server);
8684
await withOpenApi(server);
8785
await withRoutes(server);

src/server/routes/transaction/status.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
import type { SocketStream } from "@fastify/websocket";
21
import { type Static, Type } from "@sinclair/typebox";
32
import type { FastifyInstance } from "fastify";
43
import { StatusCodes } from "http-status-codes";
54
import { TransactionDB } from "../../../shared/db/transactions/db";
6-
import { logger } from "../../../shared/utils/logger";
75
import { createCustomError } from "../../middleware/error";
86
import { standardResponseSchema } from "../../schemas/shared-api-schemas";
97
import {
108
TransactionSchema,
119
toTransactionSchema,
1210
} from "../../schemas/transaction";
13-
import {
14-
findOrAddWSConnectionInSharedState,
15-
formatSocketMessage,
16-
getStatusMessageAndConnectionStatus,
17-
onClose,
18-
onError,
19-
onMessage,
20-
} from "../../utils/websocket";
2111

2212
// INPUT
2313
const requestSchema = Type.Object({
@@ -96,43 +86,6 @@ export async function getTransactionStatusRoute(fastify: FastifyInstance) {
9686
result: toTransactionSchema(transaction),
9787
});
9888
},
99-
wsHandler: async (connection: SocketStream, request) => {
100-
const { queueId } = request.params;
101-
102-
findOrAddWSConnectionInSharedState(connection, queueId, request);
103-
104-
const transaction = await TransactionDB.get(queueId);
105-
const returnData = transaction ? toTransactionSchema(transaction) : null;
106-
107-
const { message, closeConnection } =
108-
await getStatusMessageAndConnectionStatus(returnData);
109-
110-
connection.socket.send(await formatSocketMessage(returnData, message));
111-
112-
if (closeConnection) {
113-
connection.socket.close();
114-
return;
115-
}
116-
117-
connection.socket.on("error", (error) => {
118-
logger({
119-
service: "websocket",
120-
level: "error",
121-
message: "Websocket error",
122-
error,
123-
});
124-
125-
onError(error, connection, request);
126-
});
127-
128-
connection.socket.on("message", async (_message, _isBinary) => {
129-
onMessage(connection, request);
130-
});
131-
132-
connection.socket.on("close", () => {
133-
onClose(connection, request);
134-
});
135-
},
13689
});
13790
}
13891

src/server/utils/websocket.ts

Lines changed: 0 additions & 169 deletions
This file was deleted.

0 commit comments

Comments
 (0)