hapijs / yar

A hapi session manager
Other
133 stars 59 forks source link

feat: 🎸 improve yar values and flash typings #169

Open damusix opened 6 months ago

damusix commented 6 months ago
damusix commented 6 months ago

ready now

damusix commented 6 months ago

While it makes sense to more strictly type the entries, this approach seems too simple/broken.

Eg. the new generics are pointless since any override must extend from YarValues/YarFlashes. It's not possible to do request.yar.get<{ a: string }>('a') if other custom properties have been added to YarValues.

I'm also missing tests around how set(object) handles errors. Does it even error, or will it accept any object? There are multiple interesting cases here. Also, it would be nice if expect.type() was used to validate the returned types.

Thank you for the feedback it was very insightful. You actually unblocked my though process given what you alluded to about get<{ a: string }>('a'). Looking deeper into it, I even overlooked some issues that don't reflect the reality of how the library works. Currently working on an improvement with better types and tests as you suggested. Check back next week!

damusix commented 5 months ago

@kanongil

Marsup commented 5 months ago

@kanongil does it address your concerns properly?

damusix commented 3 months ago

@kanongil Mind lending a follow up? This would be cool to be able to use.