Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bimedia-fr/restify-jsonstream-bodyparser
https://github.com/bimedia-fr/restify-jsonstream-bodyparser
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bimedia-fr/restify-jsonstream-bodyparser
- Owner: bimedia-fr
- License: mit
- Created: 2015-05-29T08:20:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-08T09:37:15.000Z (over 7 years ago)
- Last Synced: 2024-12-07T20:28:55.742Z (about 1 month ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 11
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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
```javascript
server.use(require('restify-jsonstream-bodyparser')());
```### Sample
```javascript
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.