package.json
8.7 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
"_args": [
[
{
"raw": "koa-body",
"scope": null,
"escapedName": "koa-body",
"name": "koa-body",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"/Users/fzy/project/koa2_Sequelize_project/util/Agora_Recording_SDK_for_Linux_FULL/samples"
]
],
"_from": "koa-body@latest",
"_id": "koa-body@2.3.0",
"_inCache": true,
"_location": "/koa-body",
"_nodeVersion": "7.9.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/koa-body-2.3.0.tgz_1498234238163_0.22917082207277417"
},
"_npmUser": {
"name": "dlau",
"email": "dlau@ya.ru"
},
"_npmVersion": "5.0.0",
"_phantomChildren": {},
"_requested": {
"raw": "koa-body",
"scope": null,
"escapedName": "koa-body",
"name": "koa-body",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/koa-body/-/koa-body-2.3.0.tgz",
"_shasum": "33edb06471e1c2e726d506af3e5b4dce39924f1f",
"_shrinkwrap": null,
"_spec": "koa-body",
"_where": "/Users/fzy/project/koa2_Sequelize_project/util/Agora_Recording_SDK_for_Linux_FULL/samples",
"author": {
"name": "Daryl Lau",
"email": "dlau00@gmail.com",
"url": "https://github.com/dlau"
},
"bugs": {
"url": "https://github.com/dlau/koa-body/issues"
},
"contributors": [
{
"name": "Daryl Lau",
"email": "dlau00@gmail.com",
"url": "https://github.com/dlau"
},
{
"name": "Charlike Mike Reagent",
"email": "mameto_100@mail.bg",
"url": "https://github.com/tunnckoCore"
}
],
"dependencies": {
"co-body": "*",
"formidable": "1.1.1"
},
"description": "A koa body parser middleware. Support multipart, urlencoded and json request bodies.",
"devDependencies": {
"koa": "^2.0.0",
"koa-router": "^7.0.1",
"lodash": "^3.3.1",
"mocha": "*",
"multiline": "*",
"should": "*",
"supertest": "2.0.0"
},
"directories": {},
"dist": {
"integrity": "sha512-MOd8MswMgE+O9anVaOsWA4YVkmTpINZC61T3sHfmRXbb4oXasM6OcYS9Qjd8VmJtXv2b6b+xnAG+t5sCbrEbiw==",
"shasum": "33edb06471e1c2e726d506af3e5b4dce39924f1f",
"tarball": "https://registry.npmjs.org/koa-body/-/koa-body-2.3.0.tgz"
},
"files": [
".gitignore",
".npmignore",
".travis.yml",
"LICENSE",
"Makefile",
"README.md",
"example.js",
"index.js",
"test.js"
],
"gitHead": "fdf412054e7bdb5a3c305758a9bc85960b70cb86",
"homepage": "https://github.com/dlau/koa-body#readme",
"keywords": [
"koa",
"urlencoded",
"multipart",
"json",
"body",
"parser",
"form"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "dlau",
"email": "dlau00@gmail.com"
}
],
"name": "koa-body",
"optionalDependencies": {},
"readme": "koa-body [](https://travis-ci.org/dlau/koa-body) [](https://david-dm.org/dlau/koa-body)\n================\n\n> A full-featured [`koa`](https://github.com/koajs/koa) body parser middleware. Support `multipart`, `urlencoded` and `json` request bodies. Provides same functionality as Express's bodyParser - [`multer`](https://github.com/expressjs/multer). And all that is wrapped only around\n[`co-body`](https://github.com/visionmedia/co-body) and [`formidable`](https://github.com/felixge/node-formidable).\n\n## Install\n>Install with [npm](https://github.com/npm/npm)\n\n```\n$ npm install koa-body\n```\n\n## Legacy Koa1 support\n```\n$ npm install koa-body@1\n```\n\n## Features\n- can handle three type requests\n * **multipart/form-data**\n * **application/x-www-urlencoded**\n * **application/json**\n- option for patch to Koa or Node, or either\n- file uploads\n- body, fields and files limiting\n\n## Hello world\n```sh\nnpm install koa\nnpm install koa-body\nnvm install v7.9.0 #Note - koa requires node v7.6.0 for ES2015/async support\n```\nindex.js:\n```js\nconst Koa = require('koa');\nconst koaBody = require('koa-body');\n\nconst app = new Koa();\n\napp.use(koaBody());\napp.use(ctx => {\n ctx.body = `Request Body: ${JSON.stringify(ctx.request.body)}`;\n});\n\napp.listen(3000);\n```\n\n```sh\n$ node index.js\n$ curl -i http://localhost:3000/users -d \"name=test\"\nHTTP/1.1 200 OK\nContent-Type: text/plain; charset=utf-8\nContent-Length: 29\nDate: Wed, 03 May 2017 02:09:44 GMT\nConnection: keep-alive\n\nRequest Body: {\"name\":\"test\"}% \n```\n\n**For a more comprehensive example, see** `examples/multipart.js`\n\n## Usage with [koa-router](https://github.com/alexmingoia/koa-router)\n> It's generally better to only parse the body as needed, if using a router that supports middleware composition, we can inject it only for certain routes.\n\n```js\nconst Koa = require('koa');\nconst app = new Koa();\nconst router = require('koa-router')();\nconst koaBody = require('koa-body')();\n\nrouter.post('/users', koaBody,\n (ctx) => {\n console.log(ctx.request.body);\n // => POST body\n ctx.body = JSON.stringify(ctx.request.body);\n }\n);\n\napp.use(router.routes());\n\napp.listen(3000);\nconsole.log('curl -i http://localhost:3000/users -d \"name=test\"');\n```\n\n\n## Options\n> Options available for `koa-body`. Four custom options, and others are from `raw-body` and `formidable`.\n\n- `patchNode` **{Boolean}** Patch request body to Node's `ctx.req`, default `false`\n- `patchKoa` **{Boolean}** Patch request body to Koa's `ctx.request`, default `true`\n- `jsonLimit` **{String|Integer}** The byte (if integer) limit of the JSON body, default `1mb`\n- `formLimit` **{String|Integer}** The byte (if integer) limit of the form body, default `56kb`\n- `textLimit` **{String|Integer}** The byte (if integer) limit of the text body, default `56kb`\n- `encoding` **{String}** Sets encoding for incoming form fields, default `utf-8`\n- `multipart` **{Boolean}** Parse multipart bodies, default `false`\n- `urlencoded` **{Boolean}** Parse urlencoded bodies, default `true`\n- `text` **{Boolean}** Parse text bodies, default `true`\n- `json` **{Boolean}** Parse json bodies, default `true`\n- `formidable` **{Object}** Options to pass to the formidable multipart parser\n- `onError` **{Function}** Custom error handle, if throw an error, you can customize the response - onError(error, context), default will throw\n- `strict` **{Boolean}** If enabled, don't parse GET, HEAD, DELETE requests, default `true`\n\n## A note about strict mode\n> see [http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3](http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.3)\n- GET, HEAD, and DELETE requests have no defined semantics for the request body, but this doesn't mean they may not be valid in certain use cases.\n- koa-body is strict by default\n\n## Some options for formidable\n> See [node-formidable](https://github.com/felixge/node-formidable) for a full list of options\n- `bytesExpected` **{Integer}** The expected number of bytes in this form, default `null`\n- `maxFields` **{Integer}** Limits the number of fields that the querystring parser will decode, default `1000`\n- `maxFieldsSize` **{Integer}** Limits the amount of memory all fields together (except files) can allocate in bytes. If this value is exceeded, an 'error' event is emitted, default `2mb (2 * 1024 * 1024)`\n- `uploadDir` **{String}** Sets the directory for placing file uploads in, default `os.tmpDir()`\n- `keepExtensions` **{Boolean}** Files written to `uploadDir` will include the extensions of the original files, default `false`\n- `hash` **{String}** If you want checksums calculated for incoming files, set this to either `'sha1'` or `'md5'`, default `false`\n- `multiples` **{Boolean}** Multiple file uploads or no, default `true`\n- `onFileBegin` **{Function}** Special callback on file begin. The function is executed directly by formidable. It can be used to rename files before saving them to disk. [See the docs](https://github.com/felixge/node-formidable#filebegin)\n\n\n**Note**: You can patch request body to Node or Koa in same time if you want.\n\n\n## Tests\n```\n$ npm test\n```\n\n## License\nThe MIT License, 2014 [Charlike Mike Reagent](https://github.com/tunnckoCore) ([@tunnckoCore](https://twitter.com/tunnckoCore)) and [Daryl Lau](https://github.com/dlau) ([@daryllau](https://twitter.com/daryllau))\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git://github.com/dlau/koa-body.git"
},
"scripts": {
"examples-koa-router": "node --harmony examples/koa-router.js",
"examples-multer": "node --harmony examples/multer.js",
"test": "mocha"
},
"version": "2.3.0"
}