LazySessionFlavor
A lazy session flavor is a context flavor that holds a promise of some session data under ctx
.
Lazy session middleware will provide this promise lazily on the context object. Once you access ctx
, the storage will be queried and the session data becomes available. If you access ctx
again for the same context object, the cached value will be used. Check out the documentation on lazy session middleware to know more, and read the section about lazy sessions on the website.
Methods
session (getter)
// Overload 1
get session(): MaybePromise<S>;
Session data on the context object, potentially a promise.
WARNING: You have to make sure that your session data is not undefined by providing a default value to the session middleware, or by making sure that ctx
is assigned if it is empty! The type system does not include | undefined
because this is really annoying to work with.
Accessing ctx
by reading or writing will throw iff get
holds for the respective context object ctx
.