async-h

0.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i async-h

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • axdg