Attic is a cozy space with lofty ambitions. attic.social
at main 27 lines 745 B view raw
1import type { RequestEvent } from "@sveltejs/kit"; 2import type { BookmarkData } from "./valibot"; 3 4export type AuthEvent = RequestEvent & { 5 platform: App.Platform; 6}; 7 8export type UserEvent = AuthEvent & { 9 locals: App.Locals & { 10 user: NonNullable<App.Locals["user"]>; 11 }; 12}; 13 14export type BookmarkEntity = BookmarkData & { cid: string; uri: string }; 15 16export type BookmarkLoad = (cursor?: string) => Promise<{ 17 bookmarks: Array<BookmarkEntity>; 18 next?: BookmarkLoad; 19}>; 20 21export const isAuthEvent = (event: RequestEvent): event is AuthEvent => { 22 return event.platform?.env !== undefined; 23}; 24 25export const isUserEvent = (event: RequestEvent): event is UserEvent => { 26 return isAuthEvent(event) && event.locals.user !== undefined; 27};