Skip to content

Commit

Permalink
api: add /api/me.get.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsella committed Dec 22, 2024
1 parent bd56798 commit 5a6028b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/api/users/me.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getToken, getServerSession } from "#auth";

export default defineEventHandler(async (event) => {
const session = await getServerSession(event);
const token = await getToken({ event });
if (!session || !token?.email) throw createError({ statusCode: 401 });

const [user] = await db
.select()
.from(tables.users)
.where(eq(tables.users.email, token.email));
return user;
});

0 comments on commit 5a6028b

Please sign in to comment.