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

1.4.54 • Public • Published

socket.io-proxy-server

What a elegant way to proxy and intercept from socket.io connections!!!

inspired by http-proxy

Usage:

Using with Node http server

process.env['SERVER'] = 'https://the_target_socket_io_server..';
const app = require('http').createServer(handler)
const proxy = require('socket.io-proxy-server')(app);
const manager = proxy(http);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify request here...
    }
);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify response here...
    }
);

Or with koa:

const Koa = require('koa');
const app = new Koa();
const http = require('http').createServer(app.callback());
const port = process.env.PORT || 3000;
 
const proxy = require('socket.io-proxy-server');
const manager = proxy(http);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify request here...
    }
);
manager.addReqHandler(
    async function(proxySocket, packet) {
        // Modify response here...
    }
);

/socket.io-proxy-server/

    Package Sidebar

    Install

    npm i socket.io-proxy-server

    Weekly Downloads

    12

    Version

    1.4.54

    License

    ISC

    Unpacked Size

    9.21 kB

    Total Files

    9

    Last publish

    Collaborators

    • eltonzhong