-
-
Notifications
You must be signed in to change notification settings - Fork 21
Make mandatory session properties immutable #54
base: main
Are you sure you want to change the base?
Make mandatory session properties immutable #54
Conversation
ip?: string; | ||
readonly id: string; | ||
readonly createdAt: Date; | ||
readonly ip?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and, sorry to kind of push this in here, but as we're already working on the Session
interface: Would you consider adapting the h3
event context as done here:
https://github.com/sidebase/nuxt-prisma/blob/b1ffd717cf1061215498fa8e9b90ce62cac8b494/src/runtime/server/middleware/prisma.ts#L7-L11
whuile you're add it? This way, typing for the end-user should improve when they access event.context.session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it, but somehow the types aren't available when packed and imported as module in a project. Any suggestions?
Closes #2.
Checklist:
#
)Attach a session object to the event context with mandatory immutable properties
id
,createdAt
andip
.When the user wants to reassign those properties, an error is thrown. This is better than just doing nothing, because the user knows that he did something wrong in saving properties to the session in the event context.