connect-consul
v1.1.1
Published
Consul session store for Connect
Downloads
3
Maintainers
Readme
connect-consul
This a session store library that uses the Consul (HashiCorp) key/value store. Requires consul>=1.4.0.
About consul
Consul is a distributed service mesh to connect, secure, and configure services across any runtime platform and public or private cloud.
The consul has key/value storage, that used in this library for session store.
Consul lock session is used for purposes of destroy the expired session store data by setting the TTL. Lock session also defines a lock for related keys.
Setup
npm install connect-consul express-session
var session = require('express-session');
var ConsulSessionStore = require('connect-consul')(session);
var opts = { };
app.use(session({
store: new ConsulSessionStore(opts),
secret: 'keyboard cat',
resave: false
}));
Options
- opts.sessionsFolder - root folder name for session keys in KV Store ('sessions' by default)
- opts.application - the application name used in sub-folder name, for instance 'connect.sid' and in lock session name as prefix, for instance 'connect.sid:HTQQG3RS6OCdjyU...' ('connect' by default)
- opts.serializer - serializer for session store data (JSON by default)
- opts.socket - null or Consul client instance value. If it has null value, will be created a new Consul client wich is used opts as parameter.
- opts.debug - true, if need write debug messages to log (false by default)
- opts.logger - an object that should implemented methods: debug, trace, info, warn, error (undefined by default)
- opts.sessionBehavior - the consul session behavior for KV stored values of lock session. The setting values: 'delete', 'release' ('delete' by default)