Implement custom session storage
masterIf your request/response objects do not have a session property, or if you want to use an alternative storage mechanism, you must provide a custom storage object.
Your storage object must implement the following interface:
get(key: string): Promise<any>: Returns the value orundefined.set(key: string, value: any): Promise<any>: Returns the value.unset(key: string): Promise<Boolean>: Returnstrueon success.
You can pass the storage object directly, or better yet, pass a storage factory function that receives { request, response } to allow for request-specific storage instantiation.
// Using a storage factory function (recommended)
function createStorage({ request, response }) {
return new AwesomeCustomStorage(request, response);
}
// inside a route handler
smart(request, response, createStorage).authorize(options)