next/server/api/auth/session.get.ts

11 lines
259 B
TypeScript
Raw Normal View History

export default eventHandler((event) => {
if (event.context.currentUser) {
return {
token: getHeader(event, "Authorization"),
user: event.context.currentUser,
};
} else {
throw createError({ statusCode: 400, message: "unauthenticated" });
}
});