+1
-29
src/main.ts
+1
-29
src/main.ts
···
1
1
import { readFile, writeFile } from "node:fs/promises";
2
2
import { existsSync } from "node:fs";
3
-
import Redis from "ioredis";
4
-
5
-
// Monkey-patch WebSocket to work with @skyware/jetstream on Bun
6
-
// The library tries to set binaryType to 'blob' but Bun doesn't support it
7
-
const OriginalWebSocket = globalThis.WebSocket;
8
-
if (OriginalWebSocket) {
9
-
globalThis.WebSocket = class PatchedWebSocket extends OriginalWebSocket {
10
-
constructor(...args: ConstructorParameters<typeof OriginalWebSocket>) {
11
-
super(...args);
12
-
// Silently ignore binaryType changes to 'blob'
13
-
const descriptor = Object.getOwnPropertyDescriptor(this, "binaryType") ||
14
-
Object.getOwnPropertyDescriptor(OriginalWebSocket.prototype, "binaryType");
15
-
if (descriptor) {
16
-
Object.defineProperty(this, "binaryType", {
17
-
get: descriptor.get,
18
-
set: (value: string) => {
19
-
// Only set if it's arraybuffer, ignore 'blob'
20
-
if (value === "arraybuffer" && descriptor.set) {
21
-
descriptor.set.call(this, value);
22
-
}
23
-
},
24
-
enumerable: true,
25
-
configurable: true,
26
-
});
27
-
}
28
-
}
29
-
} as any;
30
-
}
31
-
32
3
import type { CommitCreateEvent } from "@skyware/jetstream";
4
+
import Redis from "ioredis";
33
5
import { Jetstream } from "@skyware/jetstream";
34
6
import { BLOB_CHECKS } from "../rules/blobs";
35
7
import { agent, isLoggedIn } from "./agent";