express-session-synchronize-socket.io
express middleware session can be attach to
socket.io
have an synchronizer session and can dist session HTTP with micro-service
Installation
npm i express-session-synchronize-socket.io --save
yarn add express-session-synchronize-socket.io
usage:
server.js
const exp = app = server = session = io = server ; app // ... you'r other middlewares // ... you'r other middlewares; app ; io // ... you'r other middlewares // ... you'r other middlewares; io ; server ;
index.html
index Lorem Ipsum <!-- only if you use socket.io module -->
arguments
middlewares optional config // ... , session = /* [pathGetSession:string] default */ "/get/session" /* return HTTP session in micro-service give null or false , if you want an manual control */ /* [autoSynchro:bool] default */ true /* synchronize HTTP session with TCP session between HTTP request you can manual use synchonize session */ // ... ,
session values
custom you access to server.js
const exp = app = server = session = io = server ; app // ... you'r other middlewares // ... you'r other middlewares; app ; io // ... you'r other middlewares // ... you'r other middlewares; io ; server ;
GET
/get/session JSON
access to HTTP
session from default route
use you HTTP
session with an micro-service
and easier build view render
with Reactjs , Angularjs , Emberjs or other framework/library Javascript
HTTP
session
custom micro-service config middleware
// ... , session = null // give null for not default route access session true // ... ,
define your routes with express e.g :
// ... , app ;
session HTTP is not save in cookies this package use local state of Nodejs for an memory store
you can thus easily imagine a structure using a notion of session server and client session the client session data being distributed in micro service for example where sent to your template in a more traditional way