import { User } from "@/interfaces/user";
import { IncomingMessage, ServerResponse } from "http";
import { NextApiRequest, NextApiResponse } from "next";

export async function requestUser(req: NextApiRequest | IncomingMessage, res: NextApiResponse | ServerResponse): Promise<User | undefined> {
	if (!req.session.user) return undefined;
	return req.session.user as User;
}
