0.0.2 • Published 7 years ago

async-h v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

async-handler

CircleCI Build Status

Everything should be made as simple as possible, but not simpler

Usage

  const { createHandler, buffer } = require('async-handler')
  
  /**
   * A simple echo server...
   *
   * Buffers the request body and
   * sends it back.
   */
  const fn = async function (req) {
    const content = await buffer(req)
    return content
  }

  const handler = createHandler(fn)

  /**
   * Or you could just send the request as
   * the response (piped under the hood).
   */
  const piper = createHandler(asnyc req => req)

API

WIP: probably not ready

createHandler(fn, catcher)

  • fn (function)
  • catcher (function)

buffer(incomingMessage, limit)

  • incomingMessage (object) - an http.incomingMessage
  • limit (number) - defaults to 1000000

LICENSE

© axdg (axdg@dfant.asia) 2017