프로젝트
GitHub에서 보기
cojs/co-body
소개
Parse request bodies with co
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalco-body
Parse request bodies with generators inspired by Raynos/body.
Installation
$ npm install co-body
Options
limitnumber or string representing the request size limit (1mb for json and 56kb for form-urlencoded)strictwhen set totrue, JSON parser will only accept arrays and objects; whenfalsewill accept anythingJSON.parseaccepts. Defaults totrue. (alsostrictmode will always return object).onProtoPoisoningDefines what action theco-bodylib must take when parsing a JSON object with__proto__. This functionality is provided by bourne. See Prototype-Poisoning for more details about prototype poisoning attacks. Possible values are'error','remove'and'ignore'. Default to'error', it will throw aSyntaxErrorwhenPrototype-Poisoninghappen.queryStringan object of options when parsing query strings and form data. See qs for more information.returnRawBodywhen set totrue, the return value ofco-bodywill be an object with two properties:{ parsed: /* parsed value */, raw: /* raw body */}.jsonTypesis used to determine what media type co-body will parse as json, this option is passed directly to the type-is library.formTypesis used to determine what media type co-body will parse as form, this option is passed directly to the type-is library.textTypesis used to determine what media type co-body will parse as text, this option is passed directly to the type-is library.
more options available via raw-body:
Example
// application/json
var body = await parse.json(req);
// explicit limit
var body = await parse.json(req, { limit: '10kb' });
// application/x-www-form-urlencoded
var body = await parse.form(req);
// text/plain
var body = await parse.text(req);
// either
var body = await parse(req);
// custom type
var body = await parse(req, { textTypes: ['text', 'html'] });
Koa
This lib also supports ctx.req in Koa (or other libraries),
so that you may simply use this instead of this.req.
// application/json
var body = await parse.json(this);
// application/x-www-form-urlencoded
var body = await parse.form(this);
// text/plain
var body = await parse.text(this);
// either
var body = await parse(this);
License
관련 프로젝트 살펴보기
불러오는 중…