huggi / src /routes /api /user /+server.ts
Kevin CATHALY
add an api endpoint to get current user's informations (#763)
b954b26 unverified
raw
history blame contribute delete
377 Bytes
export async function GET({ locals }) {
if (locals.user) {
const res = {
id: locals.user._id,
username: locals.user.username,
name: locals.user.name,
email: locals.user.email,
avatarUrl: locals.user.avatarUrl,
hfUserId: locals.user.hfUserId,
};
return Response.json(res);
}
return Response.json({ message: "Must be signed in" }, { status: 401 });
}