node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »


pull-http-router stability

npm version build status test coverage downloads js-standard-style

Minimal express-like router for pull-streams.


const pl = require('pull-level')
const summary = require('server-summary')
const toPull = require('stream-to-pull-stream')
const http = require('http')
var router = new PullHttpRouter()'/api/messages', pl.write(db), setStatus(200))
router.get('/api/messages', [ readDB (request) {
    return pull(, {min: request.query.offset}),
      offsetLimit(null, request.query.limit)
var server = http.createServer(function (req, res) {
server.listen(1337, summary(server))



Usage: router = new PullHttpRouter(opts)

Create a new PullHttpRouter.

Accepts an options object with the following optional keys:

  • router: Accepts any router object with a match and define method. Defaults to routington
  • match: Specify a specific match method for matching routes. Defaults to routington#match
  • define: Specify a specific define method for defining routes. Defaults to routington#define


Usage: router.route(opts)

Create a pull-stream which expects a request object, and returns a readable stream.

pullHttpRouter#get, pullHttpRouter#set, pullHttpRouter#update, pullHttpRouter#post, pullHttpRouter#put, pullHttpRouter#delete, pullHttpRouter#options

Usage: router.get(path, [streams...])

Accepts a path to match on, and a stream to stream to. If multiple pull-streams are provided they will be linked together as if they were passed to pull-stream core's pull()


$ npm install pull-http-router