0.0.2 • Published 7 years ago
async-h v0.0.2
async-handler
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
) - anhttp.incomingMessage
- limit (
number
) - defaults to1000000
LICENSE
© axdg • (axdg@dfant.asia) • 2017
0.0.2
7 years ago