Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-attach

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-attach

write services that attach to existing httpServer instances

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

http-attach

write services that attach to existing httpServer instances

js-standard-style Build Status

what's this for?

Let's say you want to write a small module of functionality - responding to a single http route, for example - and want to give the module a way to register itself without depending on a specific framework, like connect, express, or hapi.

This lets you implement functionality like socket.io's `socketio.attach(httpServer)``

usage

var httpAttach = require('http-attach')

function middleware (req, res, next) {
    console.log('this middleware is neat & useful')
    next()
}

middleware.attach = function (httpServer) {
    httpAttach(httpServer, middleware)
}


module.exports = middleware

httpServer should be an HttpServer or HttpsServer instance.

This replaces the existing request event handler so you can additional control point for your program logic. You can yield to the existing handler by calling the next() function you get as the third argument, like connect-style middleware.

If there is no existing request handler, calling next() will end the request with a 404 status code.

installation

$ npm install http-attach

running the tests

From package root:

$ npm install
$ npm test

contributors

license

Apache 2.0. (c) 2016 Zendesk, Inc. See LICENSE.md

Keywords

FAQs

Package last updated on 29 Jan 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc