Skip to content

Commit b460d12

Browse files
authored
refactor: use useSession generic rather than assertion (#4)
1 parent ec17cb2 commit b460d12

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/runtime/server/utils/session.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { H3Event } from 'h3'
1+
import type { H3Event, SessionConfig } from 'h3'
22
import { useSession, createError } from 'h3'
33
import { defu } from 'defu'
44
import { useRuntimeConfig } from '#imports'
55
import type { UserSession } from '#auth-utils'
66

77
export async function getUserSession (event: H3Event) {
8-
return (await _useSession(event)).data as UserSession
8+
return (await _useSession(event)).data
99
}
1010
/**
1111
* Set a user session
@@ -17,7 +17,7 @@ export async function setUserSession (event: H3Event, data: UserSession) {
1717

1818
await session.update(defu(data, session.data))
1919

20-
return session.data as UserSession
20+
return session.data
2121
}
2222

2323
export async function clearUserSession (event: H3Event) {
@@ -41,12 +41,12 @@ export async function requireUserSession(event: H3Event) {
4141
return userSession
4242
}
4343

44-
let sessionConfig: any
44+
let sessionConfig: SessionConfig
4545

4646
function _useSession (event: H3Event) {
4747
if (!sessionConfig) {
4848
// @ts-ignore
4949
sessionConfig = defu({ password: process.env.NUXT_SESSION_PASSWORD }, useRuntimeConfig(event).session)
5050
}
51-
return useSession(event, sessionConfig)
51+
return useSession<UserSession>(event, sessionConfig)
5252
}

0 commit comments

Comments
 (0)