v0.1 64c03e0

hooks.server.ts RawHistoryFolder

1import type { Handle } from "@sveltejs/kit";
2import { validateSessionToken } from "$lib/api/session.server";
3import { setSessionTokenCookie, deleteSessionTokenCookie } from "$lib/api/session.cookie";
4
5export const handle: Handle = async ({ event, resolve }) => {
6    console.debug("Handling request:", event.url.pathname);
7    
8    // Check if this is a public chat messages request
9    const isPublicChatRequest = 
10        event.url.pathname === '/api/chat/messages' && 
11        event.url.searchParams.get('public') === 'true' &&
12        event.request.method === 'GET';
13    
14    // Check if this is a public room request
15    const isPublicRoomRequest = 
16        event.url.pathname.startsWith('/api/rooms/') && 
17        event.url.searchParams.get('public') === 'true' &&
18        event.request.method === 'GET';
19    
20    // Public routes that don't require authentication
21    const publicRoutes = [
22        "/",
23        "/api/session/login",
24        "/api/session/validate",
25        "/api/register",
26        "/login",
27        "/register"
28    ];
29    
30    // Get session token from cookies
31    const token = event.cookies.get("session") ?? null;
32
33    // Handle public requests separately: always clear session
34    if (isPublicChatRequest || isPublicRoomRequest) {
35        console.debug("Public request accessed:", event.url.pathname);
36        event.locals.user = null;
37        event.locals.session = null; // Public access doesn't require a session
38        return resolve(event);
39    }
40    
41    // Handle public routes: if token exists, validate and propagate
42    if (publicRoutes.includes(event.url.pathname)) {
43        console.debug("Public route accessed:", event.url.pathname);
44        if (token) {
45            const { session, user } = await validateSessionToken(token);
46            if (session !== null) {
47                console.debug("Valid session found on public route for user:", user?.nickname);
48                setSessionTokenCookie(event, token, session.expiresAt);
49                event.locals.session = session;
50                event.locals.user = user;
51            }
52        }
53        return resolve(event);
54    }
55
56    // Protected routes: ensure authentication
57    if (token === null) {
58        console.debug("No session token found");
59        event.locals.user = null;
60        event.locals.session = null;
61        return new Response("Unauthorized", { status: 401 });
62    }
63    
64    const { session, user } = await validateSessionToken(token);
65    if (session !== null) {
66        console.debug("Valid session found for user:", user?.nickname);
67        setSessionTokenCookie(event, token, session.expiresAt);
68        event.locals.session = session;
69        event.locals.user = user;
70        return resolve(event);
71    } else {
72        console.debug("Invalid session token");
73        deleteSessionTokenCookie(event);
74        event.locals.session = null;
75        event.locals.user = null;
76        return new Response("Unauthorized", { status: 401 });
77    }
78}; 

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 3

Tags 8

↑↓ moveenter openesc close