Socket
Socket
Sign inDemoInstall

sequenz

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sequenz

sequenz composes connect middleware for nodejs


Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Install size
9.74 kB
Created
Weekly downloads
 

Readme

Source

sequenz

Build Status

sequenz composes connect middleware for nodejs

sequenz makes a single middleware from multiple middlewares

install

npm install sequenz

or

put this line in the dependencies section of your package.json:

"sequenz": "1.0.7"

then run:

npm install

use

a middleware is a function of three arguments: the request object req from the nodejs http server, the response objectres from the nodejs http server and a callback next. middleware handles the request and usually modifies the response. if a middleware doesn't end the request it should call next to give control to the next middleware.

the sequenz module exports a single function. that function either takes a single array of middlewares or any number of middlewares as separate arguments. it returns a new middleware that will call those middlewares in order.

example

the example uses some connect middleware and passage for routing.

var http = require('http');
var connect = require('connect');
var sequenz = require('sequenz');
var passage = require('passage');

var routes = sequenz(
    passage.get('/', function(req, res, next) {
        res.end('landing page');
    }),
    passage.get('/about', function(req, res, next) {
        res.end('about page');
    })
);

var middleware = sequenz(
    function(req, res, next) {
        console.log('i am a middleware that is called first on every request');
        next();
    },
    connect.favicon(),
    connect.bodyParser(),
    connect.cookieParser(),
    connect.query(),
    routes,
    function(req, res, next) {
        res.statusCode = 404;
        res.end('not found');
    }
);

var server = http.createServer(middleware);

server.listen(8080);

license: MIT

Keywords

FAQs

Last updated on 14 Feb 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc