next/server/api/auth/session.get.ts
2024-03-21 18:34:46 -04:00

12 lines
318 B
TypeScript

export default eventHandler((event) => {
let ahead = (getHeaders(event).authorization || "")?.replace("Bearer ", "");
if (event.context.currentUser && ahead) {
return {
token: ahead,
user: event.context.currentUser,
};
} else {
throw createError({ statusCode: 400, message: "unauthenticated" });
}
});