1.0.0 • Published 5 years ago
hapi-hazelcast-session v1.0.0
hapi-hazelcast-session
Server-side session for hapi, stored in Hazelcast cache server. Based on hapi-server-session.
Install
$ npm install hapi-hazelcast-session
Example
'use strict';
const hapi = require('hapi');
const main = async () => {
const server = new hapi.Server({
host: 'localhost',
address: '127.0.0.1',
port: 8000,
});
await server.register({
plugin: require('hazelcast-server-session'),
options: {
host: '127.0.0.1',
login: 'cluster_login',
password: 'cluster_password',
cookie: {
isSecure: false, // never set to false in production
},
},
});
server.route({
method: 'GET',
path: '/',
handler: (request, h) => {
request.session.views = request.session.views + 1 || 1;
return 'Views: ' + request.session.views;
},
});
await server.start();
};
main().catch(console.error);
Options
host: '127.0.0.1',
login: 'cluster_login',
password: 'cluster_password',
host
: Default:'127.0.0.1'
host of the Hazelcast serverlogin
: Default:''
group name of the Hazelcast serverpassword
: Default:''
password of the Hazelcast serveralgorithm
: Default:'sha256'
algorithm to use during signingcache
: supports the same options asserver.cache(options)
expiresIn
: Default: sessionexpiresIn
if set or2147483647
session cache expiration in millisecondssegment
: Default:'session'
session cache segment
cookie
: supports the same options asserver.state(name, [options])
isSameSite
: Default:'Lax'
sets theSameSite
flagpath
: Default:'/'
sets thePath
flagttl
: Default: sessionexpiresIn
if set sets theExpires
andMax-Age
flags
expiresIn
: session expiration in millisecondsname
: Default:'id'
name of the cookiekey
: signing key. Prevents weaknesses in randomness from affecting overall securitysize
: Default:16
number of random bytes in the session id
1.0.0
5 years ago