aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/api/v1')
-rw-r--r--src/routes/api/v1/whoami/+server.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/routes/api/v1/whoami/+server.ts b/src/routes/api/v1/whoami/+server.ts
new file mode 100644
index 0000000..98809a4
--- /dev/null
+++ b/src/routes/api/v1/whoami/+server.ts
@@ -0,0 +1,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));
+};