add maintenance mode

This commit is contained in:
Maidul Islam
2024-03-27 21:19:21 -04:00
parent 5a3fc3568a
commit 785a1389d9
4 changed files with 22 additions and 3 deletions
@@ -0,0 +1,12 @@
import fp from "fastify-plugin";
import { getConfig } from "@app/lib/config/env";
export const maintenanceMode = fp(async (fastify) => {
fastify.addHook("onRequest", async (req) => {
const serverEnvs = getConfig();
if (req.url !== "/api/v1/auth/checkAuth" && req.method !== "GET" && serverEnvs.MAINTENANCE_MODE) {
throw new Error("Infisical is in maintenance mode. Please try again later.");
}
});
});