import "server-only";
import { cache } from "react";
import { redirect } from "next/navigation";
import { getSessionFromCookies } from "@/lib/session";

export const verifySession = cache(async () => {
  const session = await getSessionFromCookies();
  if (!session?.adminId) {
    redirect("/admin/login");
  }
  return session;
});

export const getOptionalSession = cache(async () => {
  return getSessionFromCookies();
});
