1.0.0 • Published 7 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-sessionExample
'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: sessionexpiresInif set or2147483647session cache expiration in millisecondssegment: Default:'session'session cache segment
cookie: supports the same options asserver.state(name, [options])isSameSite: Default:'Lax'sets theSameSiteflagpath: Default:'/'sets thePathflagttl: Default: sessionexpiresInif set sets theExpiresandMax-Ageflags
expiresIn: session expiration in millisecondsname: Default:'id'name of the cookiekey: signing key. Prevents weaknesses in randomness from affecting overall securitysize: Default:16number of random bytes in the session id
1.0.0
7 years ago