express-rethinkdb-store
A (currently basic) implementation of a RethinkDB Session Store.
It's a complete rewrite based on express-session-rethinkdb
.
Usage
Install and save Package with
npm install --save express-rethinkdb-store
then, assuming your express
app is in app
const session = const RethinkStore = const store = app
Features
- Completely written in ES6 / ES.next
- Highly readable (See RethinkStore.js)
- Data is loaded directly from database, so no stale data in a local cache
- A cache utilizing RethinkDBs changefeeds is on the roadmap
- RethinkDB can't natively expire documents, so we remove expired sessions automatically after
flushInterval
milliseconds (60s by default). When a session gets requested it's expiry is automatically checked and, if expired, the session is removed.
API
Example with default values
connectionOptions: {} // See: https://www.rethinkdb.com/api/javascript/#connect table: "session" // Session table sessionTimeout: 86400000 // Session timeout in milliseconds flushInterval: 60000 // Interval to delete expired sessions from database
Internals
callback_decorator
Used to wrap the modern async/await functions (async functions that return a promise instead of using callbacks).
// ES.next Syntax!Store @callback_decorator async { await r }
After decoration destroy
accepts a second parameter cb
. This is required because express-session
uses
callback-style