node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »

to-middleware

to-middleware

Turn from server to connect/express middleware.

Install

$ npm install to-middleware

Usage

var middleware = require('to-middleware');
var express = require('express');
var http = require('http');
 
var server = http.createServer(function(req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Hello World\n');
});
 
var app = express();
 
app.use('/hello', middleware(server));

yields:

$ curl http://localhost:3000/hello
Hello World

License

MIT