refactor: replace Discord Gateway DO with Interaction Endpoint

This commit is contained in:
RhenCloud 2026-08-03 03:02:42 +08:00
parent 9bb9cb1444
commit d540d465d1
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
27 changed files with 834 additions and 964 deletions

View file

@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import { sendMessage } from "../discord-rest";
import { dispatchEvent, isGatewayEnabled } from "../discord";
import { dispatchEvent } from "../discord";
import type { Env, Route } from "../types";
function mockFetch(handler: (url: string, init?: RequestInit) => Response): void {
@ -12,7 +12,6 @@ function createEnv(overrides: Partial<Env> = {}): Env {
return {
GITHUB_WEBHOOK_SECRET: "secret",
KV: {} as KVNamespace,
DISCORD_GATEWAY: {} as DurableObjectNamespace,
...overrides,
};
}
@ -68,14 +67,6 @@ describe("discord-rest sendMessage", () => {
});
});
describe("isGatewayEnabled", () => {
it("is enabled only when set to true", () => {
expect(isGatewayEnabled(createEnv({ DISCORD_GATEWAY_ENABLED: "true" }))).toBe(true);
expect(isGatewayEnabled(createEnv({ DISCORD_GATEWAY_ENABLED: "false" }))).toBe(false);
expect(isGatewayEnabled(createEnv())).toBe(false);
});
});
describe("dispatchEvent fallback routing", () => {
function createMockKV(): KVNamespace {
const store = new Map<string, string>();