[READ-ONLY] a fast, modern browser for the npm registry
at main 22 lines 613 B view raw
1// This is for getting the session on the npmx server and differs from the OAuthSession 2import type { H3Event } from 'h3' 3import type { UserServerSession } from '#shared/types/userSession' 4 5/** 6 * Get's the user's session that is stored on the server 7 * @param event 8 * @returns 9 */ 10export const useServerSession = async (event: H3Event) => { 11 const config = useRuntimeConfig(event) 12 13 if (!config.sessionPassword) { 14 throw new Error('Session password is not configured') 15 } 16 17 const serverSession = useSession<UserServerSession>(event, { 18 password: config.sessionPassword, 19 }) 20 21 return serverSession 22}