Add Better Auth worker route

This commit is contained in:
2026-05-09 03:35:00 -04:00
parent 928bb3cfb0
commit 0178940e0f
13 changed files with 556 additions and 4 deletions
+2
View File
@@ -244,6 +244,8 @@ function testEnv(options: TestEnvOptions = {}): Env {
return {
ELY_ENVIRONMENT: "local",
ELY_AUTH_BASE_URL: "https://elydora.test",
ELY_AUTH_SECRET: "test-auth-secret-for-api-controls",
ELY_DB: testD1Database(),
ELY_KV: {
get(key: string): Promise<string | null> {
+2
View File
@@ -41,6 +41,8 @@ export function testEnv(options: TestEnvOptions): Env {
const values = new Map(options.kvEntries ?? []);
return {
ELY_ENVIRONMENT: "local",
ELY_AUTH_BASE_URL: "https://elydora.test",
ELY_AUTH_SECRET: "test-auth-secret-for-worker-routes",
ELY_DB: options.d1 ?? testD1Database([]),
ELY_KV: {
get(key: string): Promise<string | null> {
+13
View File
@@ -82,6 +82,17 @@ describe("worker routes", () => {
assert.deepEqual(await response.json(), { error: "not_found" });
});
it("routes Better Auth session requests under api auth", async () => {
const response = await handleRequest(
new Request("https://elydora.test/api/auth/get-session"),
testEnv(null),
);
assert.equal(response.status, 200);
assert.equal(response.headers.get("content-type"), "application/json");
assert.equal(await response.text(), "null");
});
it("returns public plugin catalog from KV", async () => {
const response = await handleRequest(
new Request("https://elydora.test/api/plugins"),
@@ -341,6 +352,8 @@ function testEnv(
return {
ELY_ENVIRONMENT: "local",
ELY_AUTH_BASE_URL: "https://elydora.test",
ELY_AUTH_SECRET: "test-auth-secret-for-worker-routes",
ELY_DB: testD1Database(),
ELY_KV: {
get(key: string): Promise<string | null> {