Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/danielroe/roe.dev. This is the code and content for my personal website, built in Nuxt. roe.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627import { clearSession, getSession, updateSession } from 'nuxt/server'import type { RequestEvent, SessionConfig } from 'nuxt/server'
type SessionData = { authenticated: boolean sponsor?: boolean avatar?: string name?: string}
const sessionConfig: SessionConfig = { name: 'token', cookie: { httpOnly: false },}
export function getUserSession (event: RequestEvent) { return getSession<SessionData>(event, sessionConfig)}
export function setUserSession (event: RequestEvent, data: Partial<SessionData>) { return updateSession<SessionData>(event, sessionConfig, data)}
export function clearUserSession (event: RequestEvent) { return clearSession(event, sessionConfig)}