import { NextRequest } from "next/server";
import { authenticatedApiClient } from "@/modules/api/v2/auth/authenticated-api-client";
import { responses } from "@/modules/api/v2/lib/response";
import { handleApiError } from "@/modules/api/v2/lib/utils";
import { getRoles } from "@/modules/api/v2/roles/lib/utils";

export const GET = async (request: NextRequest) =>
  authenticatedApiClient({
    request,
    handler: async () => {
      const res = getRoles();

      if (res.ok) {
        return responses.successResponse(res.data);
      }

      return handleApiError(request, res.error);
    },
  });
