Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/electric-proxy/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface Env {
JWKS_URL: string;
JWT_ISSUER: string;
JWT_AUDIENCE: string;
ELECTRIC_URL: string;
ELECTRIC_SECRET?: string;
}
15 changes: 7 additions & 8 deletions apps/electric-proxy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { verifyJWT } from "./auth";
import type { Env } from "./env";
import { buildWhereClause } from "./where-clauses";

export interface Env {
JWKS_URL: string;
JWT_ISSUER: string;
JWT_AUDIENCE: string;
ELECTRIC_URL: string;
ELECTRIC_SECRET: string;
}
export type { Env } from "./env";

const ELECTRIC_PROTOCOL_PARAMS = new Set([
"live",
Expand Down Expand Up @@ -100,8 +95,8 @@ export default {
return corsResponse(400, `Unknown table: ${table}`);
}

// Build Electric query params
const originUrl = new URL(env.ELECTRIC_URL);
originUrl.searchParams.set("secret", env.ELECTRIC_SECRET);
originUrl.searchParams.set("table", table);
originUrl.searchParams.set("where", whereClause.fragment);

Expand All @@ -119,6 +114,10 @@ export default {
}
}

if (env.ELECTRIC_SECRET) {
originUrl.searchParams.set("secret", env.ELECTRIC_SECRET);
}

const response = await fetch(originUrl.toString(), {
cf: { cacheEverything: true },
});
Expand Down
5 changes: 4 additions & 1 deletion apps/electric-proxy/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
"name": "electric-proxy",
"account_id": "6ac34a81594ea52ff7ed2f24b9108e41",
"main": "src/index.ts",
"compatibility_date": "2025-01-01",
"compatibility_date": "2026-02-12",
"vars": {
"JWKS_URL": "https://api.superset.sh/api/auth/jwks",
"JWT_ISSUER": "https://api.superset.sh",
"JWT_AUDIENCE": "https://api.superset.sh"
},
"observability": {
"enabled": true
}
}
Loading