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

    brick-serverpublic

    brick-server

    NPM version build status Test coverage Downloads js-standard-style

    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

    License

    MIT

    install

    npm i brick-server

    Downloadsweekly downloads

    0

    version

    1.0.0

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar
    • avatar