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

union

Package Overview
Dependencies
Maintainers
4
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

union

A hybrid buffered / streaming middleware kernel backwards compatible with connect.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created

What is union?

The 'union' npm package is a hybrid routing HTTP server with a powerful middleware ecosystem. It is designed to create custom Node.js HTTP servers by combining various middleware and routing logic. Union is particularly useful for building applications that require a high level of customization in their HTTP server behavior.

What are union's main functionalities?

Custom Server Creation

This code sample demonstrates how to create a custom HTTP server using Union. The 'before' array allows you to add middleware functions that process requests before they reach your main logic.

const union = require('union');
const http = require('http');

const server = union.createServer({
  before: [
    function (req, res) {
      res.emit('next');
    }
  ]
});

server.listen(3000, function () {
  console.log('Server running on port 3000');
});

Middleware Integration

This example shows how to integrate a routing library, 'director', as middleware in a Union server. The router's dispatch method is bound and used as middleware, allowing for route handling within the Union server.

const union = require('union');
const director = require('director');

const router = new director.http.Router();
const server = union.createServer({
  before: [
    function (req, res) {
      res.emit('next');
    },
    router.dispatch.bind(router)
  ]
});

Other packages similar to union

FAQs

Package last updated on 18 Jan 2024

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