socket.io-cookies-parser
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

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);
...

Package Sidebar

Install

npm i socket.io-cookies-parser

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

4.08 kB

Total Files

10

Last publish

Collaborators

  • nqnghia285