koa-session-socketio
v1.0.0
Published
socket.io middleware to get session from cookie, this is useful when running socket.io independently from any http framework such as koa/express
Downloads
17
Maintainers
Readme
koa-session-socketio
socket.io middleware to get session from cookie, this is useful when running socket.io independently from any http framework such as koa/express
Installation
npm i koa-session-socketio
Example
const Server = require('socket.io')
const session = require('koa-session-socketio')
const redisStore = require('koa-redis')
const redisConfig = {
host: 'localhost',
port: 6379
}
const store = redisStore(redisConfig)
const io = new Server('3000')
io.use(session('koa.sess', store))
io.on('connection', socket => {
// socket.session contains session object
})
API
session(name, store, [opts])
name
Type: string
session key id
store
Type: Object
koa-session
store object