Scheduling infrastructure for absolutely everyone.
chore: Remove inMaintenanceMode from APIv1 for increased robustness (#24576)
Alex van Andel17944311c373
diff --git a/apps/api/v1/lib/helpers/checkIsInMaintenanceMode.ts b/apps/api/v1/lib/helpers/checkIsInMaintenanceMode.tsdeleted file mode 100644index 8f2f0879b32..00000000000--- a/apps/api/v1/lib/helpers/checkIsInMaintenanceMode.ts+++ /dev/null@@ -1,23 +0,0 @@-import { get } from "@vercel/edge-config";-import type { NextMiddleware } from "next-api-middleware";--const safeGet = async <T = unknown>(key: string): Promise<T | undefined> => {- try {- return get<T>(key);- } catch (error) {- // Don't crash if EDGE_CONFIG env var is missing- }-};--export const config = { matcher: "/:path*" };--export const checkIsInMaintenanceMode: NextMiddleware = async (req, res, next) => {- const isInMaintenanceMode = await safeGet<boolean>("isInMaintenanceMode");- if (isInMaintenanceMode) {- return res- .status(503)- .json({ message: "API is currently under maintenance. Please try again at a later time." });- }-- await next();-};diff --git a/apps/api/v1/lib/helpers/withMiddleware.ts b/apps/api/v1/lib/helpers/withMiddleware.tsindex 3b06627ccc6..ff409fba51c 100644--- a/apps/api/v1/lib/helpers/withMiddleware.ts+++ b/apps/api/v1/lib/helpers/withMiddleware.ts@@ -3,7 +3,6 @@ import { label } from "next-api-middleware";import { addRequestId } from "./addRequestid";import { captureErrors } from "./captureErrors";import { captureUserId } from "./captureUserId";-import { checkIsInMaintenanceMode } from "./checkIsInMaintenanceMode";import { extendRequest } from "./extendRequest";import {HTTP_DELETE,@@ -26,7 +25,6 @@ const middleware = {HTTP_POST,HTTP_DELETE,addRequestId,- checkIsInMaintenanceMode,verifyApiKey,rateLimitApiKey,extendRequest,@@ -38,16 +36,14 @@ const middleware = {type Middleware = keyof typeof middleware;-const middlewareOrder = [- // The order here, determines the order of execution- "checkIsInMaintenanceMode",+const middlewareOrder: Middleware[] = ["extendRequest","captureErrors","verifyApiKey","rateLimitApiKey","addRequestId","captureUserId",-] as Middleware[]; // <-- Provide a list of middleware to call automatically+];const withMiddleware = label(middleware, middlewareOrder);