Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Latest commit

History

81 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

sequenz

NPM PackageBuild Statuscodecov.ioDownloads per Month

sequenz composes connect middleware for nodejs

sequenz makes a single middleware from multiple middlewares

install

npm install sequenz

use

a middleware is a function of three arguments: the request objectreq 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.

varhttp=require('http');varconnect=require('connect');varsequenz=require('sequenz');varpassage=require('passage');varroutes=sequenz(passage.get('/',function(req,res,next){res.end('landing page');}),passage.get('/about',function(req,res,next){res.end('about page');}));varmiddleware=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');});varserver=http.createServer(middleware);server.listen(8080);

license: MIT

About

sequenz composes connect middleware for nodejs

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages