mw-cls
Advanced CLS (continuation local storage) middleware (for express, restify, ...)
Namespace middleware
var session = cls;
.run()
run the following middleware within the namespace
var cls = ;var session = cls; app;
.set(key, val [, forceCreateKeypath=true])
set the namespace key with a value
var cls = ;var session = cls; app; # requiredapp;
.asyncSet(key, val [, opts={forceCreateKeypath:true, includeError:false}])
set the namespace key as the result of an async function
var cls = ;var session = cls; app; # requiredapp; // session.get('foo').bar.baz becomes 'value' { ;}
includeError option
var cls = ;var session = cls; app; # requiredapp; // session.get('foo').bar.baz becomes [null, 'value'] { ;}
.send([code, ]key [, forceReturnKeypath=true])
// forceReturnKeypath means no errors if keypath DNE
res.send the value for the namespace key
var cls = ;var session = cls; app; # requiredapp; // res.sends 'value', code defaults to 200
.json([code, ]key [, forceReturnKeypath=true])
// forceReturnKeypath means no errors if keypath DNE
res.json the value for the namespace key
var cls = ;var session = cls; app; # requiredapp; // res.sends { bar: 'value' }, code defaults to 200
TODO methods
mv, cp, del, unset, setFromReq
License
MIT