New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wob

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wob

minimalist http server wrapper

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
Created
Source

wob

minimalist http server wrapper

Installation

npm install wob

Examples

var fs = require('fs')
  , Browserify = require('browserify')
  , Stylus = require('stylus-fs')

wob.createServer(function(req) {
  if (req.url === '/index.js')
    return Browserify(__dirname + req.url)
  if (req.url === '/index.css')
    return Stylus(__dirname + req.url.replace(/\.css$/, '.styl'))
  if (req.url === '/index.html')
    return fs.createReadStream(__dirname + req.url)
  throw wob.status[404]
})

Passing headers

wob.createServer(function(req) {
  return stream.on('piped', function(res) {
    res.setHeader('Content-Type', 'x-weird/weirdness')
  })
})

API

wob(function(req, res) -> Response)

Wrap a wob request handler so you can feed it to http.createServer

A promise will be resolved. A Stream will be piped to the response stream (return stream is pretty much equivalent to doing stream.pipe(res) in core-http) Any other value will be serialised to JSON and sent as response.

Thrown errors are also serialised to JSON. If they have a .statusCode property, that'll be set as status code.

wob.createServer(function(req, res) -> Response)

Shorthand for http.createServer(wob(fn))

Response

Stream | Value | Promise<Response>

License

MIT

Keywords

web

FAQs

Package last updated on 05 Mar 2014

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