aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-21 01:13:25 +0000
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-09-21 01:13:25 +0000
commit9d26295c65d2c68ae5012bea1b20ea7e45e93325 (patch)
tree3616eccafc248e25eb7f0e8c93e15b2863e8a502 /src/routes
parent11877824040ed2b92dab0efe04d7b24c64fa39cd (diff)
downloadcrunched-9d26295c65d2c68ae5012bea1b20ea7e45e93325.tar.gz
crunched-9d26295c65d2c68ae5012bea1b20ea7e45e93325.tar.bz2
crunched-9d26295c65d2c68ae5012bea1b20ea7e45e93325.tar.lz
crunched-9d26295c65d2c68ae5012bea1b20ea7e45e93325.zip

feat: misc changes before hopefully actually starting

HEADmaster
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/+layout.svelte6
-rw-r--r--src/routes/api/v1/vms/list/+server.ts12
-rw-r--r--src/routes/api/v1/whoami/+server.ts40
-rw-r--r--src/routes/aup/+page.svelte3
-rw-r--r--src/routes/scope-prompt/[scopes]/+server.ts6
-rw-r--r--src/routes/vms/+page.ts5
6 files changed, 66 insertions, 6 deletions
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index 61bd14e..c8e4917 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -14,7 +14,11 @@
<nav class="header">
<h1 class="text-4xl">crunched</h1>
<p>
- <a href="/home">home</a> - {#if page.data.session}<a href="/vms">vms</a> -
+ <a href="/home" data-sveltekit-preload-code="viewport">home</a> - {#if page.data.session}<a
+ href="/vms"
+ data-sveltekit-preload-code="viewport">vms</a
+ >
+ -
<a
href="/login/undo?next={encodeURIComponent(
page.url.pathname + page.url.search
diff --git a/src/routes/api/v1/vms/list/+server.ts b/src/routes/api/v1/vms/list/+server.ts
new file mode 100644
index 0000000..7bbf8f3
--- /dev/null
+++ b/src/routes/api/v1/vms/list/+server.ts
@@ -0,0 +1,12 @@
+import { error, json } from '@sveltejs/kit';
+import { 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({
+ todo: 'implement',
+ });
+};
diff --git a/src/routes/api/v1/whoami/+server.ts b/src/routes/api/v1/whoami/+server.ts
index 98809a4..2b7d430 100644
--- a/src/routes/api/v1/whoami/+server.ts
+++ b/src/routes/api/v1/whoami/+server.ts
@@ -3,7 +3,41 @@ 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));
+
+ // note: these return types are JUST for this endpoint - rely on status code exclusively for the actual meaning.
+ const headers = {
+ 'Access-Control-Allow-Origin': '*',
+ };
+ if (data === undefined)
+ return json(
+ {
+ '': '',
+ kind: 'NOT_AUTHENTICATED' as const,
+ message: 'Unauthenticated',
+ },
+ {
+ status: 403,
+ statusText: 'Forbidden',
+ headers,
+ }
+ );
+ if (data === null)
+ return json(
+ {
+ '': '',
+ kind: 'EXPIRED' as const,
+ message: 'Session Expired',
+ },
+ {
+ status: 401,
+ statusText: 'Unauthorized',
+ headers,
+ }
+ );
+
+ return json(filterSession(data), {
+ headers,
+ status: 200,
+ statusText: 'OK :3',
+ });
};
diff --git a/src/routes/aup/+page.svelte b/src/routes/aup/+page.svelte
index 66601ae..cf25031 100644
--- a/src/routes/aup/+page.svelte
+++ b/src/routes/aup/+page.svelte
@@ -47,7 +47,8 @@
</ol>
<p class="mt-2">
Tl;dr: Abide by the same general rules any other provider provides. Try not
- to violate regional laws in Zurich, Switzerland.
+ to violate regional laws in Zurich, Switzerland. Don't do anything you
+ wouldn't want your friends to do on your internal network.
</p>
<h2 class="text-2xl mt-4">Excessive Resource Use Policy</h2>
<p>
diff --git a/src/routes/scope-prompt/[scopes]/+server.ts b/src/routes/scope-prompt/[scopes]/+server.ts
index f919b9c..5521cf5 100644
--- a/src/routes/scope-prompt/[scopes]/+server.ts
+++ b/src/routes/scope-prompt/[scopes]/+server.ts
@@ -17,5 +17,9 @@ export const GET = async (e) => {
)
)
throw redirect(303, base + '/scope-prompt/ok');
- else throw error(500, 'In server mode, this branch should be unreachable');
+ else
+ throw error(
+ 500,
+ 'In server mode, this branch should be unreachable. checkScope with getScopeOnFail should never return false outside of the client.'
+ );
};
diff --git a/src/routes/vms/+page.ts b/src/routes/vms/+page.ts
new file mode 100644
index 0000000..fb0ce3c
--- /dev/null
+++ b/src/routes/vms/+page.ts
@@ -0,0 +1,5 @@
+export const load = ({ fetch }) => {
+ return {
+ todo: 'use /api/v1/vms/list',
+ };
+};