msda-session-server-client

0.0.3 • Public • Published

#msda-session-server-client

#embed into express

var express = require('express');
var session = require('express-session');

var SSC = require('msda-session-server-client');

var app = express();

app.use(session({
  store: new SSC({
    host: 'localhost',
    port: '3018',
    path: '/api/'
  }),
  secret: 'something',
  resave: false,
  saveUninitialized: false,
  cookie: {secure: false}
}));

#calling the methods form sessionManager

var sessionManager = require('msda-session-server-client').sessionManager;


router.get('/session/:userToken/:key/:value', function (req, response, next) {
    var p = {};
    p[req.params.key] = req.params.value;
    sessionManager.openSession(req, req.params.userToken, p, function (err, res) {
        response.json(res);
    })
});

router.get('/session/:userToken/:key/:value/:sessionActiveTime', function (req, response, next) {
    var p = {};
    p[req.params.key] = req.params.value;
    sessionManager.openSessionWithSessionActiveTime(req, req.params.userToken, p, req.sessionActiveTime function (err, res) {
        response.json(res);
    })
});


router.get('/session/:key/:value', function (req, response, next) {
    req.session[req.params.key] = req.params.value;
    req.session.save(function (err, res) {
        response.json(res);
    })
});

router.get('/session/logout', function (req, response, next) {
    sessionManager.closeSession(req, function (err, res) {
        response.json(res);
    })
});


router.get('/session', function (req, res, next) {
    res.json(sessionManager.getData(req));
});

Readme

Keywords

none

Package Sidebar

Install

npm i msda-session-server-client

Weekly Downloads

0

Version

0.0.3

License

none

Last publish

Collaborators

  • levansuper