brick-server
v1.0.0
Published
Create an http handler for brick-router
Downloads
4
Readme
brick-server
Create an http handler for
brick-router
.
Sends out ndjson events. Works well with
opnr and
garnish.
Installation
$ npm install brick-server
Usage
const brickRouter = require('brick-router')
const brickServer = require('brick-server')
const http = require('http')
const router = brickRouter()
// streams
router.on('/index.html', (cb) => {
const loc = path.join(__dirname, 'index.html')
const stream = fs.createReadStream(loc)
cb(null, stream)
})
// strings
router.on('/index.css', (cb) => {
const css = `
.foo {
color: blue;
}
`
cb(null, css)
})
const handler = brickServer(router.match)
const server = http.createServer(handler)
server.listen(1337)
See Also
- brick-router - modular router for serving static assets
- opnr - launches the browser when ndjson criteria is met
- garnish - prettifies ndjson from wzrd and similar tools