Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yujinlim/koa-session-socketio
socket io middleware to parse cookie value on header from koa-session package
https://github.com/yujinlim/koa-session-socketio
Last synced: 15 days ago
JSON representation
socket io middleware to parse cookie value on header from koa-session package
- Host: GitHub
- URL: https://github.com/yujinlim/koa-session-socketio
- Owner: yujinlim
- License: mit
- Created: 2018-05-13T06:31:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-13T07:37:10.000Z (over 6 years ago)
- Last Synced: 2024-12-07T20:56:01.715Z (about 1 month ago)
- Language: JavaScript
- Size: 28.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-session-socketio [![Build Status](https://img.shields.io/travis/yujinlim/koa-session-socketio.svg?style=flat-square)](https://travis-ci.org/yujinlim/koa-session-socketio) ![npm](https://img.shields.io/npm/dt/koa-session-socketio.svg?style=flat-square) ![npm](https://img.shields.io/npm/v/koa-session-socketio.svg?style=flat-square)
> 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
```bash
npm i koa-session-socketio
```## Example
```js
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