aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/api/v1/whoami/+server.ts
blob: 98809a456e3eb3a10a9cc1e132d1e41ba15e0426 (plain) (blame)
1
2
3
4
5
6
7
8
9
import { error, json } from '@sveltejs/kit';
import { filterSession, type Session } from '../../../../hooks.server.js';

export const GET = async ({ locals }) => {
  const data = (await locals.auth()) as Session;
  if (data === undefined) throw error(403, 'Unauthorized');
  if (data === null) throw error(401, 'Session Expired');
  return json(filterSession(data));
};