import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
import { checkAuthorizationHeader, checkAuthorizationHeaderNoThrow } from "#lib/middleware/authorization.js";
import { AstroGlobal } from "astro";

export function getCurrentUser(Astro: AstroGlobal) {
	const accessToken = Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value;

	return checkAuthorizationHeaderNoThrow(`Bearer ${accessToken}`)
}