-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.json
33 lines (33 loc) · 3.19 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"name": "raw-body",
"description": "Get and validate the raw body of a readable stream.",
"version": "0.0.3",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/stream-utils/raw-body.git"
},
"bugs": {
"url": "https://github.com/stream-utils/raw-body/issues"
},
"devDependencies": {
"mocha": "~1.12"
},
"scripts": {
"test": "make test"
},
"readme": "# Raw Body [![Build Status](https://travis-ci.org/stream-utils/raw-body.png)](https://travis-ci.org/stream-utils/raw-body)\n\nGets the entire buffer of a stream and validates its length against an expected length and limit.\nIdeal for parsing request bodies.\n\nThis is the callback version of [cat-stream](https://github.com/jonathanong/cat-stream), which is much more convoluted because streams suck.\n\n## API\n\n```js\nvar getRawBody = require('raw-body')\n\napp.use(function (req, res, next) {\n getRawBody(req, {\n expected: req.headers['content-length'],\n limit: 1 * 1024 * 1024 // 1 mb\n }, function (err, buffer) {\n if (err)\n return next(err)\n\n req.rawBody = buffer\n next()\n })\n})\n```\n\n### Options\n\n- `expected` - The expected length of the stream.\n If the contents of the stream do not add up to this length,\n an `400` error code is returned.\n- `limit` - The byte limit of the body.\n If the body ends up being larger than this limit,\n a `413` error code is returned.\n\n### Strings\n\nThis library only returns the raw buffer.\nIf you want the string,\nyou can do something like this:\n\n```js\ngetRawBody(req, function (err, buffer) {\n if (err)\n return next(err)\n\n req.text = buffer.toString('utf8')\n next()\n})\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2013 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.",
"readmeFilename": "README.md",
"homepage": "https://github.com/stream-utils/raw-body",
"_id": "raw-body@0.0.3",
"dist": {
"shasum": "659db25be53c8735e90eee2b964516da2a31905d"
},
"_from": "raw-body@0.0.3",
"_resolved": "https://registry.npmjs.org/raw-body/-/raw-body-0.0.3.tgz"
}