From f59a33b06492aa1c63e2018bc9f0b151828f8e63 Mon Sep 17 00:00:00 2001 From: Brian Cooper Date: Sun, 5 Jul 2026 19:52:42 -0500 Subject: [PATCH] refactor(flags): remove maintenance-mode check (operator-native now) --- .env.local.template | 3 --- .env.production | 3 --- src/lib/config/env.config.ts | 5 ----- src/lib/middleware/maintenance.ts | 24 ------------------------ src/lib/providers/index.ts | 14 -------------- src/server.ts | 2 -- 6 files changed, 51 deletions(-) delete mode 100644 src/lib/middleware/maintenance.ts diff --git a/.env.local.template b/.env.local.template index 10aff442..74e9fd14 100644 --- a/.env.local.template +++ b/.env.local.template @@ -29,9 +29,6 @@ BILLING_WEBHOOK_SECRET="" VORTEX_API_URL="https://localhost:5000" VORTEX_API_KEY="" -# feature flags -FLAGS_CLIENT_KEY= - # object storage (feedback attachments) # Optional: when S3_BUCKET is unset, uploads use a noop provider and bytes are # not persisted. Works with any S3-compatible store (AWS S3, R2, MinIO, Railway). diff --git a/.env.production b/.env.production index 3b57857d..d126fec5 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,3 @@ AUTH_BASE_URL="https://identity.omni.dev" CHECKOUT_SUCCESS_URL="https://backfeed.omni.dev/confirmation" - -# feature flags -FLAGS_API_HOST=https://flags.omni.dev/api diff --git a/src/lib/config/env.config.ts b/src/lib/config/env.config.ts index 260b87e3..d2e7da42 100644 --- a/src/lib/config/env.config.ts +++ b/src/lib/config/env.config.ts @@ -27,9 +27,6 @@ export const { VORTEX_API_KEY, // Auth webhook AUTH_WEBHOOK_SECRET, - // Feature flags - FLAGS_API_HOST, - FLAGS_CLIENT_KEY, // Meilisearch (unified search) MEILISEARCH_URL, MEILISEARCH_MASTER_KEY, @@ -102,8 +99,6 @@ if (!AUTHZ_API_URL) console.warn("AUTHZ_API_URL not set, authorization disabled"); if (!VORTEX_API_URL) console.warn("VORTEX_API_URL not set, event streaming disabled"); -if (!FLAGS_API_HOST) - console.warn("FLAGS_API_HOST not set, feature flags disabled"); if (!MEILISEARCH_URL) console.warn("MEILISEARCH_URL not set, search disabled"); if (!S3_BUCKET) console.warn( diff --git a/src/lib/middleware/maintenance.ts b/src/lib/middleware/maintenance.ts deleted file mode 100644 index 45262529..00000000 --- a/src/lib/middleware/maintenance.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Elysia } from "elysia"; -import { flags } from "lib/providers"; - -/** - * Maintenance mode middleware. - * Returns 503 Service Unavailable when maintenance mode is enabled. - * Health check endpoint is always allowed through. - */ -export const maintenanceMiddleware = new Elysia({ name: "maintenance" }).derive( - async ({ request, set }) => { - const url = new URL(request.url); - - // Allow health checks through - if (url.pathname === "/health") return {}; - - if (await flags.isEnabled("backfeed-api-maintenance-mode")) { - set.status = 503; - set.headers["Retry-After"] = "300"; - throw new Error("Service temporarily unavailable for maintenance"); - } - - return {}; - }, -); diff --git a/src/lib/providers/index.ts b/src/lib/providers/index.ts index a8cbb64e..565fc1d0 100644 --- a/src/lib/providers/index.ts +++ b/src/lib/providers/index.ts @@ -9,7 +9,6 @@ import { createAuthzProvider, createBillingProvider, createEventsProvider, - createFlagProvider, createNotificationProvider, createStorageProvider, } from "@omnidotdev/providers"; @@ -18,8 +17,6 @@ import { AUTHZ_SERVICE_KEY, BILLING_BASE_URL, BILLING_SERVICE_API_KEY, - FLAGS_API_HOST, - FLAGS_CLIENT_KEY, HERALD_API_KEY, HERALD_API_URL, HERALD_DEFAULT_FROM, @@ -80,17 +77,6 @@ export const notifications = createNotificationProvider( : {}, ); -export const flags = createFlagProvider( - FLAGS_API_HOST - ? { - provider: "unleash", - url: FLAGS_API_HOST, - apiKey: FLAGS_CLIENT_KEY!, - appName: "backfeed-api", - } - : {}, -); - /** * Object storage for feedback attachments. * diff --git a/src/server.ts b/src/server.ts index e8d8f576..6c2b651c 100644 --- a/src/server.ts +++ b/src/server.ts @@ -31,7 +31,6 @@ import { import idpWebhook from "lib/idp/webhooks"; import attachmentServeRoutes from "lib/media/serve.route"; import attachmentUploadRoutes from "lib/media/upload.route"; -import { maintenanceMiddleware } from "lib/middleware/maintenance"; import { SEARCH_RECONCILE_INTERVAL_MS, initializeSearchIndexes, @@ -111,7 +110,6 @@ async function startServer(): Promise { set.headers["Referrer-Policy"] = "strict-origin-when-cross-origin"; }) .get("/health", () => ({ status: "ok", commit })) - .use(maintenanceMiddleware) .use( rateLimit({ max: 100,