Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restify jsonstream body parser

When using server.use(restify.bodyParser(), content is buffered being passed through to restify bodyParser.

With very large content, this quickly becomes a bottleneck, hanging restify thread while reading data.

This library allow to manually bypass the default bodyParser behaviour to avoid blocking the main event loop, by providing a stream (or JSON stream) instead. This is to the user of the plugin to define if the content will be processed as a stream or as an object. All other requests are left unchanged.

Usage

Setting

server.use(require('restify-jsonstream-bodyparser')());

Sample

server.post({
    url: '/',
    streamer: {
        pattern: '*'
    }
}, function (req, res, next) {
    req.body.pipe(es.writeArray(function (err, content) {
        res.send(err ? 400 : 200, content);
    }))
    .on('end', res.end);
});

Options

As for any restify middleware, you can pass options. Those options will get forwarded to the default bodyParser if used.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

10 watching

Forks

Releases

Packages

Used by

Contributors

Languages