alexa-ability-stash
An alexa-ability middleware for persistent user storage.
Warning: Still in development. Not suitable for use in production yet.
Example
;;;; // or any compatible express-session store const RedisStore = ;const store = options;const app = ; app; app; const handler = ;
API
createStash(options) -> middleware
Creates a middleware function to handle the stash.
Takes the following options:
store
- one of the stores defined belowgenid
- a function that takes a request object and returns a string. Returns<appId>:<userId>
by default.unset
- Behavior whenreq.stash
is deleted.destroy
orkeep
. Defaults tokeep
.keep
The stash will be kept, but modifications made during the request are ignored and not saved.destroy
: The stash will be destroyed (deleted) when the response ends.
resave
Forces the stash to be saved, even if the stash was never modified. Defaults totrue
.
Attaches two properties to the request object:
stash
an object you can read and modify. Changes will be saved across requests.stashId
the id generated bygenid
.
Stores
Theoretically all the store supported by express-session should work. In practice, only connect-redis has been tested.
If a store doesn't work for you raise an issue!