From d6b33bfc7bad28379717f105cb158a15cca68b33 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 13 Feb 2026 12:14:14 -0800 Subject: [PATCH] chore(electric-proxy): extract env types, enable observability, make secret optional Move Env interface to dedicated env.ts file. Enable Cloudflare observability. Make ELECTRIC_SECRET optional for local dev without it. --- apps/electric-proxy/src/env.ts | 7 +++++++ apps/electric-proxy/src/index.ts | 15 +++++++-------- apps/electric-proxy/wrangler.jsonc | 5 ++++- 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 apps/electric-proxy/src/env.ts diff --git a/apps/electric-proxy/src/env.ts b/apps/electric-proxy/src/env.ts new file mode 100644 index 00000000000..adf24501605 --- /dev/null +++ b/apps/electric-proxy/src/env.ts @@ -0,0 +1,7 @@ +export interface Env { + JWKS_URL: string; + JWT_ISSUER: string; + JWT_AUDIENCE: string; + ELECTRIC_URL: string; + ELECTRIC_SECRET?: string; +} diff --git a/apps/electric-proxy/src/index.ts b/apps/electric-proxy/src/index.ts index 130969e6276..3276fcaf6eb 100644 --- a/apps/electric-proxy/src/index.ts +++ b/apps/electric-proxy/src/index.ts @@ -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", @@ -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); @@ -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 }, }); diff --git a/apps/electric-proxy/wrangler.jsonc b/apps/electric-proxy/wrangler.jsonc index 6f6d2c268fc..6e1bedc7338 100644 --- a/apps/electric-proxy/wrangler.jsonc +++ b/apps/electric-proxy/wrangler.jsonc @@ -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 } }