🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

bizzby-silly-server-factory

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bizzby-silly-server-factory

a factory for making http servers with

latest
npmnpm
Version
3.0.0
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Silly Server Factory

Handles (some of) the pain of creating a non-ssl proxy-protocol spdy/http2 understanding server

Read the index.js for docs/comments etc.

Basics

  • Creates and returns an http server like thing
  • Attaches the request listener for you (attaching listeners after instantion leads to duplicate requests and bad things and is totally not supported and who-knows-what unexpected behaviour may happen)
  • Does not "start"/"listen" the server

Usage

var factory = require('bizzby-silly-server-factory')

// This could be an express app
var myRequestHandler = function(req, res){

    if(req.isSpdy) {
        console.log('SPDY/HTTP2 request, spdyVersion %s, stream %s', req.spdyVersion, req.spdyStream.id)
    }
    
    console.log('remote IP = ' + req.connection.remoteAddress + ':' + req.connection.remotePort)
    // these will be undefined if the connection does send the proxy protocol headers
    console.log('proxy IP = ' + req.connection.proxyAddress + ':' + req.connection.proxyPort)
    console.log('client IP = ' + req.connection.clientAddress + ':' + req.connection.clientPort)

    res.writeHead(200)
    res.end('ok')
}

// Set this otherwise they default to false :-)
var someOpts = {
  proxyprotocol: true,
  spdy: true
}

var myServer = factory(someOpts, myRequestHandler).listen(9100)

FAQs

Package last updated on 04 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts