Something went wrong. Try again.
Get an ever updating ics link for all the events you RSVP to on the Atmosphere whenslunch.app
Something went wrong. Try again.
665 B · 16 lines
TypeScript
at public
1234567891011121314151617import type { Handle, ServerInit } from '@sveltejs/kit/hooks';import { DATABASE_URL } from '$app/env/private';import { db } from '#lib/server/db/index.js';import { runMigrations } from '#lib/server/db/migrate.js';import { SESSION_COOKIE, getSessionUser } from '#lib/server/auth/session.js';
export const init: ServerInit = async () => { await runMigrations(DATABASE_URL);};
export const handle: Handle = async ({ event, resolve }) => { const id = event.cookies.get(SESSION_COOKIE); event.locals.user = id ? await getSessionUser(db, id) : null; if (id && !event.locals.user) event.cookies.delete(SESSION_COOKIE, { path: '/' }); return resolve(event);};