import { AuthResponse } from "../../src/types"; import { logger } from "./logger"; import * as Sentry from "@sentry/node"; import { configDotenv } from "dotenv"; configDotenv(); let warningCount = 0; export function withAuth( originalFunction: (...args: U) => Promise, mockSuccess: T, ) { return async function (...args: U): Promise { const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === "true"; if (!useDbAuthentication) { if (warningCount < 5) { logger.warn("You're bypassing authentication"); warningCount++; } return { success: true, ...(mockSuccess || {}) } as T; } else { return await originalFunction(...args); } }; }