ArangoDB session store for Connect.
via npm:
$ npm install connect-arango
hash
(optional) Hash is an object, which will determine wether hash the sid in arango, since it's not undefined, means sid will be hashedhash.salt
Salt will be used to hash the sid in arango, default salt is "connect-arango"hash.algorithm
Hash algorithm, default algorithm is "sha1"db
Database name OR fully instantiated ArangoDB objectcollection
Collection (optional, default:sessions
)host
ArangoDB server hostname (optional, default:127.0.0.1
)port
ArangoDB server port (optional, default:8529
)username
Username (optional)password
Password (optional)url
Connection url of the form:http://user:pass@host:port/_db/database/_admin/aardvark/standalone.html#collection/collection
. If provided, information in the URL takes priority over the other options.stringify
If true, connect-arango will serialize sessions usingJSON.stringify
before setting them, and deserialize them withJSON.parse
when getting them. (optional, default: true). This is useful if you are using types that ArangoDB doesn't support.serialize
Custom hook for serializing sessions to arangoDB. This is helpful if you need to modify the session before writing it out.unserialize
Custom hook for unserializing sessions from ArangoDB. This can be used in scenarios where you need to support different types of serializations (e.g., objects and JSON strings) or need to modify the session before using it in your app.clear_interval
The amount of milliseconds to wait between session accesses to clear expired sessions.
The second parameter to the ArangoStore
constructor is a callback which will be called once the database is ready.
With express4:
var session = require( "express-session" );
var ArangoStore = require( "connect-arango" )( session );
app.use( session( {
secret: settings.cookie_secret,
store: new ArangoStore( {
db : settings.db,
} )
} ) );
With express<4:
var express = require('express');
var ArangoStore = require('connect-arango')(express);
app.use( express.session( {
secret: settings.cookie_secret,
store: new ArangoStore( {
db: settings.db
} )
} ) );
With connect:
var connect = require('connect');
var ArangoStore = require('connect-arango')(connect);
Since ArangoDB does not have a TTL entry for documents, this is done using an AQL query in the session store.
Every time a session is accessed, it will clear expired sessions, but only if it has passed more than clear_interval
milliseconds (default 60 seconds)
between each access.
Feel free to contribute anything you would like. I will make sure to check pull requests as often as I can.
(The MIT License)
Copyright (c) 2014 Metamist
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.