npm.io
1.1.1 • Published 5 years ago

socket.io-cookies-parser

Licence
MIT
Version
1.1.1
Deps
5
Size
4 kB
Vulns
0
Weekly
0
Stars
1

Socket.IO Cookies Parser Build Status

Socket.IO Cookies Parser help us handle cookie for Socket.IO

Note: After setup success, socket.request.cookies was parsed to JSON object.

Functions:

/**
 * @method namespaceCookieParser setup socket midleware for namespace instance
 * @param socket Socket
 */
function namespaceCookieParser(socket: Socket): void;
/**
 * @method ioCookieParser setup socket midleware for io instance
 * @param socket Socket
 * @param next (err?: ExtendedError | undefined) => void
 */
function ioCookieParser(socket: Socket, next: (err?: ExtendedError | undefined) => void): void;
Example:
//ES6
import socketio from "socket.io";
import { namespaceCookieParser, ioCookieParser } from "socket.io-cookies-parser";
...
const io = new socketio.Server();
io.use(ioCookieParser);
...
const client = io.of("/client", namespaceCookieParser);
...

Keywords