import { asyncRoute, ok } from "@infra/http";
import { isBasicAuthEnabled } from "@server/infra/basic-auth-credentials";
import { type Request, type Response, Router } from "express";

export const authRouter = Router();

/**
 * GET /api/auth/basic-status — public; whether write operations require Basic Auth.
 */
authRouter.get(
  "/basic-status",
  asyncRoute(async (_req: Request, res: Response) => {
    return ok(res, { basicAuthEnabled: isBasicAuthEnabled() });
  }),
);

/**
 * POST /api/auth/verify — requires Basic Auth when enabled; confirms credentials.
 */
authRouter.post(
  "/verify",
  asyncRoute(async (_req: Request, res: Response) => {
    return ok(res, { valid: true });
  }),
);
