Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
269 commits
Select commit Hold shift + click to select a range
d0546cb
fixes #3
Oct 24, 2014
82383b0
remove npmignore
Oct 24, 2014
6098ed8
v1.0.5
Oct 24, 2014
cb34f39
badge, coverage battle
Oct 25, 2014
862372c
badge, coverage battle
Oct 25, 2014
2efac4b
97% coverage
Oct 25, 2014
e2e925e
97% coverage
Oct 25, 2014
46d983b
oops, delete index2.js
Oct 25, 2014
9c1f3d9
update automation
Oct 25, 2014
527d7cd
add makefile, improve coverage
Oct 25, 2014
a88f7ae
v1.0.6
Oct 25, 2014
e706480
oops, fix
Oct 25, 2014
9f081d0
update new 413 header name
Oct 26, 2014
1506800
v1.0.7
Oct 26, 2014
249bc7f
ooops, forgot to update history.md
Oct 26, 2014
e6ab11f
release v1.0.7
Oct 26, 2014
864a1fd
v1.0.7
Oct 26, 2014
f8027d6
v1.0.7
Oct 26, 2014
7c58040
commit from .bashrc
Nov 26, 2014
805dba0
commit from .bashrc
Nov 26, 2014
0445a16
Release v1.0.8
Nov 26, 2014
338d530
bump `jscs-jsdoc` and .jscsrc
Nov 26, 2014
16dd267
Release v1.0.9
Nov 26, 2014
ae60c5e
testing verb 0.3.0
Nov 26, 2014
bd8f06e
update node version, coveralls.yml, tweaks
Nov 26, 2014
b66d7c9
Release v1.0.10
Nov 26, 2014
8550818
fix code style collisions
Nov 26, 2014
c83b943
Release v1.0.11
Nov 26, 2014
d23a5a5
bump jscs and jscs-jsdoc
Nov 26, 2014
4e104a2
Release v1.0.12
Nov 26, 2014
bd15a98
Adding option to change `files` key
pepkin88 Jan 13, 2015
ad075db
Fix error, where `defaults` get mutated
pepkin88 Jan 14, 2015
8a2ccca
docs
Jan 17, 2015
3fa60a3
update dotfiles
Jan 17, 2015
b7af608
update package.json
Jan 17, 2015
09221c7
run lint
Jan 17, 2015
9ae33f8
update license year
Jan 17, 2015
e80f666
add test for custom filesKey option
Jan 17, 2015
8372812
fix scripts
Jan 17, 2015
2105c33
fix scripts tests
Jan 17, 2015
dcf506a
fix license year in dotfiles
Jan 17, 2015
75d20c3
fix travis
Jan 17, 2015
63b637e
fix license in jshint
Jan 17, 2015
0dc34a2
Release v1.0.13
Jan 17, 2015
7f88332
closes #10, update/add tests
Jan 17, 2015
219beb6
increase max statements to 20
Jan 17, 2015
c532d13
coverage tweaks
Jan 17, 2015
a979d1b
istanbul ignore
Jan 17, 2015
12f9f73
Release v1.0.14
Jan 17, 2015
bfeac66
add `encode` alias for `encoding` option
Jan 19, 2015
d8c6206
Release v1.0.15
Jan 19, 2015
54758f5
add `opts.extendTypes`
Jan 19, 2015
2071b5d
Release v1.0.16
Jan 19, 2015
ff3b91d
bump deps
Feb 6, 2015
706b9ce
update keywords
Feb 6, 2015
68b0aba
run update readme
Feb 6, 2015
5daaa83
fix license range
Feb 6, 2015
fe7a4b4
back `formidable` to ~1.0.16, which no matters
Feb 6, 2015
903bd13
Release v1.0.17
Feb 6, 2015
a9f6f91
faster travis and iojs + v0.12 support
Feb 8, 2015
a39b865
Use co-better-body and enable qs options
dan-dr Feb 11, 2015
3cd49a3
Update docs
dan-dr Feb 11, 2015
a4fb927
run update readme
tunnckoCore Feb 15, 2015
7b7a445
update docblock
tunnckoCore Feb 15, 2015
df556d3
Delete request fails
carlitux Apr 2, 2015
57c4591
add notice for v2
tunnckoCore May 6, 2015
a24f791
Updated readme to reflect actual defaults for fieldsKey and filesKey.
Sep 30, 2015
229772b
register formidable events via config, fix #27
creeperyang Jan 26, 2016
39d2859
add test for formidable event
creeperyang Jan 26, 2016
88f4c02
don't break on empty bodies (empty posts)
sedenardi Apr 3, 2016
1298af1
v2 (#34)
tunnckoCore Apr 15, 2016
9832c17
Release v2.0.0
Apr 15, 2016
de5fdfd
chore(package): update lazy-cache to version 2.0.0 (#41)
greenkeeperio-bot Apr 29, 2016
26ad7de
downloads badge
May 5, 2016
cca5c67
switch to use `mukla` for testing
May 5, 2016
dfd133b
fix description
May 5, 2016
1f45daa
Release v2.0.1
May 5, 2016
88ddd1e
chore(package): update mukla to version 0.4.1 (#44)
greenkeeperio-bot May 9, 2016
42d015d
fixes #50: no more writing to `ctx.body` - everything is only on `ctx…
Jul 9, 2016
3f77c27
update docs
Jul 9, 2016
5cedd02
chore(package): update supertest to version 2.0.0 (#54)
greenkeeperio-bot Jul 30, 2016
e00e923
fix for standard@8
Sep 3, 2016
72ec5a0
add opts.urlencodedLimit alias for opts.formLimit
Sep 3, 2016
9bdf2a9
address #52: split buffer parsing from text parsing
Sep 3, 2016
8a15940
address #52: implement extendTypes.custom and opts.handler
Sep 3, 2016
3e184ac
call opts.handler with context, update test for extendTypes.custom
Sep 3, 2016
895a36b
noop generator function opts.handler
Sep 3, 2016
51e449f
fix context of multipart parser, fix typo
Sep 7, 2016
8b76355
add options.handler docs
Sep 8, 2016
0f9408d
add querystring option; add notes about extendTypes and querystring p…
Sep 9, 2016
d2fc80d
add tests for `app.querystring` and `opts.querystring`
Sep 9, 2016
cba0469
update tests
Sep 9, 2016
4b3c484
fix codeclimate "issue"
Sep 9, 2016
ce5464b
docs: closes #51
Sep 9, 2016
336fc00
run verb, docs #51
Sep 9, 2016
ec562a1
update travis, gitignore, npm scripts, devDeps
Sep 9, 2016
744b128
fixes #55, fixes #61, update tests, add `form` recipe
Sep 9, 2016
bcf685a
fallback mode for opts.delimiter -> opts.sep
Sep 9, 2016
fdaf3b8
update docs: document new options and the aliases
Sep 9, 2016
aca3b27
fix possible build fails
Sep 9, 2016
9d0c68d
update contributing guide
Sep 9, 2016
bb68078
fix links in contributing.md
Sep 9, 2016
d415d90
chore(dotfiles): update dotfiles, npm scripts, hooks, CONTRIBUTING.md
Sep 11, 2016
d4a9a7f
Release v3.0.0
Sep 12, 2016
c2ab7df
chore(example.js): add working `koa-router` example in root
Oct 8, 2016
6d8b9f1
docs(example): add section for `koa-router` with working `./example.js`
Oct 8, 2016
5dc6a73
fix(package.json): update npm scripts, remove some devDeps
Oct 8, 2016
bc0ca71
chore(release): 3.0.1
Oct 8, 2016
5c08652
fix(utils.js): qs: query string parsing options
Oct 8, 2016
5feb70b
chore(release): 3.0.2
Oct 8, 2016
40043f9
fix(ampersand): bug when value has ampersand
manuscriptmastr Apr 14, 2017
776be30
fix(doc): update extendTypes link (#82)
poppinlp Apr 24, 2017
64bda04
fix(koa2): remove ctx.querystring (#84)
wisdom-yzh May 11, 2017
41c0cb4
fix(readme): update router example
tunnckoCore Jul 15, 2017
a0e7139
chore(release): 3.0.3
Jul 16, 2017
f9f8023
fix(style): update standard and format codebase
Jul 16, 2017
568e419
fix(prettier): format codebase
Jul 16, 2017
ee08407
fix(lint): update linting, remove lazy-cache
Jul 16, 2017
94066fb
fix(package): update scripts and travis
Jul 16, 2017
5146914
fix(travis): install more stable npm for better results
Jul 16, 2017
fff4396
fix(style): proper naming
Jul 16, 2017
a15528c
chore(release): 3.0.4
Jul 16, 2017
1ce4e91
fix(readme): add note for the new v4 release
tunnckoCore Jul 16, 2017
a6a6f12
Configure Renovate (#92)
renovate[bot] Jul 28, 2017
3a66883
refactor(deps): Renovate Pin Dependencies packages
renovate[bot] Jul 28, 2017
6374717
chore(deps): Update dependency cz-conventional-changelog to version 2…
renovate[bot] Jul 28, 2017
090d218
chore(renovate): hm, test `automerge: any`
tunnckoCore Jul 28, 2017
ee68f7e
chore(deps): Update dependency koa-route to version 3.2.0
renovate[bot] Jul 28, 2017
7d8fee0
chore(deps): Update dependency nyc to version 11.0.3
renovate[bot] Jul 28, 2017
1e38843
chore(deps): Update dependency standard-version to version 4.2.0
renovate[bot] Jul 28, 2017
455d36a
chore(deps): Update dependency supertest to version 3.x (#101)
renovate[bot] Jul 28, 2017
4bb0973
chore(deps): Update dependency nyc to version 11.1.0
renovate[bot] Jul 29, 2017
fdd0e1f
chore(deps): update dependency eslint to v4.4.0
renovate[bot] Aug 5, 2017
3a834e9
chore(deps): update dependency standard to v10.0.3
renovate[bot] Aug 6, 2017
3e068fa
chore(deps): update dependency eslint to v4.4.1
renovate[bot] Aug 7, 2017
9af10c0
chore(deps): update dependency eslint to v4.5.0
renovate[bot] Aug 19, 2017
3809e8b
chore(deps): update dependency npm-run-all to v4.1.0
renovate[bot] Aug 26, 2017
3cae770
chore(deps): update lock file
renovate[bot] Aug 28, 2017
aa1bf86
chore(deps): update dependency npm-run-all to v4.1.1
renovate[bot] Aug 28, 2017
463eada
chore(deps): update dependency eslint to v4.6.0
renovate[bot] Sep 1, 2017
46be4c2
chore(deps): update dependency eslint to v4.6.1
renovate[bot] Sep 3, 2017
8c0157e
chore(deps): update dependency nyc to v11.2.0
renovate[bot] Sep 5, 2017
8da092d
chore(deps): update dependency nyc to v11.2.1
renovate[bot] Sep 6, 2017
c6cf651
chore(deps): update dependency qs to v6.5.1
renovate[bot] Sep 9, 2017
92fed16
chore(deps): update lock file
renovate[bot] Sep 11, 2017
95f56f3
chore(deps): update dependency eslint to v4.7.0
renovate[bot] Sep 15, 2017
cdb2735
chore(deps): update dependency eslint to v4.7.1
renovate[bot] Sep 18, 2017
56773a6
chore(deps): update dependency eslint to v4.7.2
renovate[bot] Sep 21, 2017
e83d22f
chore(deps): update lock file
renovate[bot] Sep 25, 2017
74dea0a
chore(deps): update dependency coveralls to v2.13.2
renovate[bot] Sep 28, 2017
0af9a36
chore(deps): update dependency coveralls to v2.13.3
renovate[bot] Sep 28, 2017
24f1883
chore(deps): update dependency coveralls to v3.0.0
renovate[bot] Sep 28, 2017
568cbe5
chore(deps): update dependency eslint to v4.8.0
renovate[bot] Sep 29, 2017
bdbc4db
chore(deps): update lock file
renovate[bot] Oct 2, 2017
1e2f2e5
chore(deps): update lock file
renovate[bot] Oct 9, 2017
0516f59
chore(deps): update dependency koa to v1.4.1
renovate[bot] Oct 9, 2017
3b3407c
chore(deps): update dependency eslint to v4.9.0
renovate[bot] Oct 14, 2017
c3a1b69
chore(deps): update dependency is-buffer to v1.1.6
renovate[bot] Oct 25, 2017
f868aa6
chore(deps): update dependency cz-conventional-changelog to v2.1.0
renovate[bot] Oct 27, 2017
8bdfdfb
chore(deps): update dependency eslint to v4.10.0
renovate[bot] Oct 27, 2017
d370894
chore(deps): update lock file
renovate[bot] Oct 30, 2017
e1b2f6e
chore(deps): update dependency eslint to v4.17.0
renovate-bot Feb 3, 2018
4ec9062
chore(deps): update dependency koa to v1.5.1
renovate-bot Feb 9, 2018
0e93393
chore(deps): update dependency npm-run-all to v4.1.2
renovate-bot Feb 9, 2018
ee7d7d4
chore(deps): update dependency nyc to v11.4.1
renovate-bot Feb 9, 2018
7feb352
chore(deps): update dependency standard-version to v4.3.0
renovate-bot Feb 9, 2018
f1af628
chore(deps): update dependency is-buffer to v2.0.0
renovate-bot Feb 9, 2018
912653d
fix(deps): update dependency extend-shallow to v3.0.2
renovate-bot Feb 10, 2018
9d611fb
chore(deps): update dependency koa to v1.6.0
renovate-bot Feb 12, 2018
38e8ba3
chore(deps): update dependency eslint to v4.18.1
renovate-bot Feb 20, 2018
e677a06
chore(deps): update dependency eslint to v4.18.2
renovate-bot Mar 2, 2018
7095fd4
chore(deps): update dependency koa to v2.5.0
renovate-bot Mar 4, 2018
92eb1a0
fix(deps): update dependency formidable to v1.2.0
renovate-bot Mar 7, 2018
b829bf9
chore(deps): update dependency standard to v11.0.0
renovate-bot Mar 8, 2018
05e32d8
chore(deps): update dependency nyc to v11.6.0
renovate-bot Mar 13, 2018
316a49a
chore(deps): update dependency standard to v11.0.1
renovate-bot Mar 14, 2018
087aacc
chore(deps): update dependency eslint to v4.19.0
renovate-bot Mar 16, 2018
acd3dff
fix(deps): update dependency formidable to v1.2.1
renovate-bot Mar 20, 2018
d0e8b7e
chore(deps): update dependency eslint to v4.19.1
renovate-bot Apr 10, 2018
9d4dd2f
chore(deps): update dependency koa to v2.5.1
renovate-bot Apr 26, 2018
a76531a
chore(deps): update dependency is-buffer to v2.0.2
renovate-bot Apr 27, 2018
d76e89f
chore(deps): update dependency coveralls to v3.0.1
renovate-bot May 1, 2018
1ab3a6d
chore(deps): update dependency npm-run-all to v4.1.3
renovate-bot May 6, 2018
6dfb8fa
chore(deps): update dependency supertest to v3.1.0
renovate-bot May 13, 2018
fa91802
chore(deps): update dependency nyc to v11.7.3
renovate-bot May 14, 2018
4821ef3
chore(deps): update dependency nyc to v11.8.0
renovate-bot May 15, 2018
818bb6e
chore(deps): update dependency standard-version to v4.4.0
renovate-bot May 22, 2018
5b5f3d4
chore(deps): update dependency commitizen to v2.10.1
renovate-bot May 24, 2018
8af5a7a
chore(deps): update dependency nyc to v12
renovate-bot Jun 1, 2018
3640159
chore(deps): update dependency nyc to v12.0.2
renovate-bot Jun 3, 2018
13204f3
chore(deps): update dependency is-buffer to v2.0.3
renovate-bot Jun 9, 2018
6f15df9
chore(deps): update dependency eslint to v5
renovate-bot Jun 23, 2018
7ba4d59
chore(deps): update dependency eslint to v5.0.1
renovate-bot Jun 26, 2018
67fecad
chore(deps): update dependency coveralls to v3.0.2
renovate-bot Jun 29, 2018
9c1fab4
chore(deps): update dependency eslint to v5.1.0
renovate-bot Jul 8, 2018
1acfc6f
chore(deps): update dependency koa to v2.5.2
renovate-bot Jul 12, 2018
d1b0101
chore(deps): update dependency eslint to v5.2.0
renovate-bot Jul 21, 2018
7ac8b0f
chore(deps): update dependency qs to v6.5.2
renovate-bot Jul 22, 2018
0452374
chore(deps): update dependency eslint to v5.3.0
renovate-bot Aug 4, 2018
0b9ace5
chore(deps): update dependency eslint to v5.4.0
renovate-bot Aug 18, 2018
f4e2c1f
chore(deps): update dependency nyc to v13
renovate-bot Aug 27, 2018
3934f62
chore(deps): update dependency eslint to v5.5.0
renovate-bot Sep 1, 2018
a67c9ad
chore(deps): update dependency supertest to v3.2.0
renovate-bot Sep 5, 2018
63bb3a3
chore(deps): update dependency supertest to v3.3.0
renovate-bot Sep 6, 2018
678f5c8
chore(deps): update dependency koa to v2.5.3
renovate-bot Sep 11, 2018
a43bad5
chore(deps): update dependency eslint to v5.6.0
renovate-bot Sep 15, 2018
a7d65e5
chore(deps): update dependency eslint to v5.6.1
renovate-bot Sep 28, 2018
a515366
chore(deps): update dependency commitizen to v3
renovate-bot Oct 1, 2018
343813b
chore(deps): update dependency commitizen to v3.0.2
renovate-bot Oct 3, 2018
7a721af
chore(deps): update dependency eslint to v5.7.0
renovate-bot Oct 12, 2018
1a6d565
chore(deps): update dependency nyc to v13.1.0
renovate-bot Oct 14, 2018
dbbac65
chore(deps): update dependency commitizen to v3.0.4
renovate-bot Oct 20, 2018
9f219c4
chore(deps): update dependency koa to v2.6.1
renovate-bot Oct 24, 2018
d1c5161
chore(deps): update dependency eslint to v5.8.0
renovate-bot Oct 26, 2018
b1f7c0e
chore(deps): update dependency koa to v2.6.2
renovate-bot Nov 9, 2018
fb9b0a7
chore(deps): update dependency eslint to v5.9.0
renovate-bot Nov 10, 2018
9933708
chore(deps): update dependency npm-run-all to v4.1.5
renovate-bot Nov 24, 2018
65cce19
chore(deps): update dependency qs to v6.6.0
renovate-bot Nov 25, 2018
ff74d52
chore(deps): update dependency commitizen to v3.0.5
renovate-bot Nov 27, 2018
587325b
chore(deps): update dependency eslint to v5.10.0
renovate-bot Dec 8, 2018
7fdd2e6
chore(deps): update dependency eslint to v5.11.0
renovate-bot Dec 23, 2018
659b8d6
chore(deps): update dependency eslint to v5.11.1
renovate-bot Dec 27, 2018
380d8a4
chore(deps): update dependency eslint to v5.12.0
renovate-bot Jan 4, 2019
e9aa7c5
chore(deps): update dependency supertest to v3.4.1
renovate-bot Jan 16, 2019
b972378
chore(deps): update dependency eslint to v5.12.1
renovate-bot Jan 18, 2019
ba60a3f
chore(deps): update dependency supertest to v3.4.2
renovate-bot Jan 22, 2019
66d0273
chore: update renovate config
Jun 1, 2019
3a6e94f
chore: switch to semanticPrefixFixDepsChoreOthers
Jun 1, 2019
eb60b6a
chore: update readme stuff
Jun 1, 2019
cc7ebcc
chore(deps): update dependency coveralls to v3.0.3 (#188)
renovate[bot] Jun 1, 2019
6836d8d
chore(deps): update dependency commitizen to v3.1.1 (#187)
renovate[bot] Jun 1, 2019
dcafd36
chore(deps): update dependency supertest to v4 (#194)
renovate[bot] Jun 1, 2019
91d5bee
chore(deps): update dependency eslint to v5.16.0 (#189)
renovate[bot] Jun 1, 2019
518ae73
chore(deps): update dependency standard-version to v6 (#193)
renovate[bot] Jun 1, 2019
dafc920
chore: lock koa to v1 tag
Jun 3, 2019
3360e05
chore: delete package-lock
Jun 3, 2019
60e958b
chore(travis): do not update npm to latest
Jun 3, 2019
a700ee9
chore(travis): do no test on Node 4 & 5
Jun 3, 2019
fcff747
chore(deps): update dependency coveralls to v3.0.4
renovate-bot Jun 5, 2019
69226fa
chore(deps): update dependency coveralls to v3.0.5
renovate-bot Jul 12, 2019
028c798
chore(deps): update dependency commitizen to v3.1.2
renovate-bot Jul 17, 2019
47c8644
chore(deps): update dependency commitizen to v4
renovate-bot Jul 18, 2019
043b2ab
chore(deps): update dependency commitizen to v4.0.1
renovate-bot Jul 19, 2019
d44aff5
chore(deps): update dependency commitizen to v4.0.2
renovate-bot Jul 19, 2019
e1932ee
chore(deps): update dependency cz-conventional-changelog to v3
renovate-bot Jul 19, 2019
7efba7c
chore(deps): update dependency commitizen to v4.0.3
renovate-bot Jul 20, 2019
b4cf457
chore(deps): update dependency cz-conventional-changelog to v3.0.2
renovate-bot Jul 21, 2019
c7877e7
chore(deps): update dependency standard-version to v7
renovate-bot Jul 30, 2019
2bad316
chore(deps): update dependency coveralls to v3.0.6
renovate-bot Aug 6, 2019
95ed596
chore(deps): update dependency qs to v6.8.0
renovate-bot Aug 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/koa-better-body/.codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
languages:
JavaScript: true
exclude_paths:
- "test/**.js"
12 changes: 12 additions & 0 deletions packages/koa-better-body/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
insert_final_newline = false
29 changes: 29 additions & 0 deletions packages/koa-better-body/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"extends": "standard",
"rules": {
"generator-star-spacing": ["error", { "before": true, "after": true }],
"computed-property-spacing": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"arrow-parens": ["error", "always"],
"max-params": "error",
"max-nested-callbacks": [
"error",
{
"max": 5
}
],
"max-depth": [
"error",
{
"max": 5
}
],
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
]
}
}
73 changes: 73 additions & 0 deletions packages/koa-better-body/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Always-ignore dirs #
# ####################
_gh_pages
node_modules
jspm_packages
bower_components
components
vendor
build
dest
dist
src
lib-cov
coverage
nbproject
cache
temp
tmp
koa-better-body

# Packages #
# ##########
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# OS, Logs and databases #
# #########################
logs
*.pid
*.dat
*.log
*.sql
*.sqlite
*~
~*

# Another files #
# ###############
Icon?
.DS_Store*
Thumbs.db
ehthumbs.db
Desktop.ini
npm-debug.log
.directory
._*
lcov.info

# Runtime data
pids
*.pid
*.seed
*.pid.lock


# nyc test coverage
.nyc_output

# Grunt intermediate storage
# see here: http://gruntjs.com/creating-plugins#storing-task-files
.grunt

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
10 changes: 10 additions & 0 deletions packages/koa-better-body/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sudo: false
language: node_js

node_js:
- "node"
- "6"


notifications:
email: false
241 changes: 241 additions & 0 deletions packages/koa-better-body/.verb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# [{%= name %}][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url]

> {%= description %}

[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]

You might also be interested in our [recipes](./recipes) - working examples, answers, tips & tricks. [Contribute a recipe?](#contributing-recipes)

## Install
```
npm i {%= name %} --save
```

## Features
- Work for `koa@1` and `koa@2` (with deprecation messages), will also work in `koa@3` with [koa-convert][]
- Totally flexible through `options` and absolutely lightweight using [lazy-cache][]
- Accept few JSON types
- Accept [JSON Patch [RFC6902]](https://tools.ietf.org/html/rfc6902) ([koajs/bodyparser#8](https://github.com/koajs/bodyparser/pull/8))
- Accept [JSON API v1](http://jsonapi.org/) ([koajs/bodyparser#7](https://github.com/koajs/bodyparser/pull/7))
- Accept [JSON csp-report](https://mathiasbynens.be/notes/csp-reports) ([#3](https://github.com/tunnckoCore/koa-better-body/issues/3))
- Accept text and buffer bodies
- Accept urlencoded and forms bodies
- Accept multipart form data files and fields
- Can parse correctly array data from forms - e.g. multiple fields to have same name - [dlau/koa-body#15](https://github.com/dlau/koa-body/pull/15)
- Can parse correctly forms that accept multiple files - see [#26](https://github.com/tunnckoCore/koa-better-body/issues/26) and [dlau/koa-body#15](https://github.com/dlau/koa-body/pull/15)
- Strict mode by default - see why on [IETF Message Semantics: Section 6.1](https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.1)
- Custom JSON request detect function - [koajs/bodyparser#f6a5ff](https://github.com/koajs/bodyparser/commit/f6a5ff7ef6162702540b101de5dde71ee5ad19cd)
- Custom error handling function - [koajs/bodyparser#19418129](https://github.com/koajs/bodyparser/commit/194181298fe3bffce6b5fcf3cfebc35b8cda6c89)
- Extending types of request that your app can accept - [koajs/bodyparser#ba7479b](https://github.com/koajs/bodyparser/commit/ba7479baf893fc3391fcdb88d3d8173ac4df05e7)
- Using awesome [formidable][] package - [„battle-tested against hundreds of GB of file uploads“](https://github.com/felixge/node-formidable#current-status)
- Passing a custom `formidable.IncomingForm` instance, allowing awesome customization
- Passing all options to `formidable.IncomingForm`, allowing awesome control


## Usage
> For more use-cases see the [tests](./test.js)

```js
const {%= varname %} = require('{%= name %}')
```

## Working with [koa-router][]

```js
'use strict'

var app = require('koa')()
var body = require('{%= name %}')
var router = require('koa-router')()

router.post('/upload', body(), function * (next) {
console.log(this.request.files)
console.log(this.request.fields)

// there's no `.body` when `multipart`,
// `urlencoded` or `json` request
console.log(this.request.body)

// print it to the API requester
this.body = JSON.stringify({
fields: this.request.fields,
files: this.request.files,
body: this.request.body || null
}, null, 2)

yield next
})

app.use(router.routes())
app.listen(4292)

var format = require('util').format
var host = 'http://localhost:4292'
var cmd = 'curl -i %s/upload -F "source=@%s/.editorconfig"'

console.log('Try it out with below CURL for `{%= name %}` repository.')
console.log(format(cmd, host, __dirname))
```

{%= apidocs('index.js') %}

## Options
Sane defaults. :sparkles:

Accepts JSON, [JSON API v1](http://jsonapi.org/), text, buffer, [csp-report](https://mathiasbynens.be/notes/csp-reports), multipart and urlencoded/form bodies. If you want to disallow accepting and parsing multipart body you should pass `multipart: false`. Most of the defaults you can see at [utils.defaultOptions and utils.defaultTypes](./utils.js). **All `options` are also been passed to [formidable][].IncomingForm!** Even you can pass IncomingForm instance to be able to handle the different formidable events.

- `fields` **{Boolean|String}**: Default `false`, which means it will set fields on `this.request.fields`. If you pass a string, for example `'foo'`, you will have fields on `this.request.foo`.
- `files` **{Boolean|String}**: Default `false`, which means it will set files on `this.request.files`. If you pass a string, for example `'bar'`, you will have files on `this.request.bar`.
- `multipart` **{Boolean}**: Default `true`. If you pass `false` it won't accept/parse multipart bodies.
- `textLimit` **{String}**: Default `'100kb'`. Passed to [bytes][].parse method.
- `formLimit` **{String}**: Default `'100kb'`. Passed to [bytes][].parse method.
- `urlencodedLimit` **{String}**: Default `'100kb'`. Alias of `opts.formLimit`.
- `jsonLimit` **{String}**: Default `'100kb'`. Passed to [bytes][].parse method.
- `bufferLimit` **{String}**: Default `'1mb'`. Passed to [bytes][].parse method.
- `jsonStrict` **{Boolean}**: Default `true`. When set to true, JSON parser will only accept arrays and objects.
- `detectJSON` **{Function}**: Custom JSON request detect function - `detectJSON(ctx)`.
- `strict` **{Boolean}**: Default `true`. Pass `false` if you want to allow parsing GET, DELETE and HEAD requests.
- `onerror` **{Function}**: Custom error handle, if throw an error, you can customize the response - `onerror(err, ctx)`.
- `extendTypes` **{Object}**: Default accepting types can find on [utils.defaultTypes function](./utils.js#L83-L104). Allowing you to extend what your app can accept. By default works for JSON, [JSON API v1](http://jsonapi.org/), multipart, text, urlencoded and [csp-report](https://mathiasbynens.be/notes/csp-reports).
- `IncomingForm` **{IncomingForm}**: Pass an instance of `formidable.IncomingForm` to be able to handle formidable events.
- `handler` **{GeneratorFunction}**: Works with `options.extendTypes.custom` to handle custom types of content-type - `handler(ctx, options, next)`. More info below.
- `querystring` **{Object}**: Querystring module to be used. By default builtin [`querystring`](https://nodejs.org/api/querystring.html). More info below.
- `qs` **{Object}**: Alias of `opts.querystring`. All `opts` are also passed to [qs][] or [querystring module](https://nodejs.org/api/querystring.html).
- `delimiter` **{String}**: Default is `&`. Delimiter of key/value pairs, passed to querystring lib
- `sep` **{String}**: alias of `opts.delimiter`
- `buffer` **{Boolean}**: Default `false`, pass `true` if you want to get body as buffer.

## Note about `options.extendTypes`

ExandTypes option gives you a flexible way to handle different content-types and modify the defaults which can be found [at utils.defaultTypes function](./utils.js#L83-L104). In addition you can pass combination of `options.extendTypes.custom` and `options.handler`. When the request has some of the "custom" content type, this middleware will call the `handler` **generator** function with `ctx, options, next`. You can see more at [issue #52](https://github.com/tunnckoCore/koa-better-body/issues/52).

For example manually handle such content types `foo/bar-x`, `text/quix`:

```js
const app = require('koa')()
const body = require('koa-better-body')

app.use(body({
textLimit: '300kb'
extendTypes: {
custom: [
'foo/bar-x',
'text/quix'
]
},
handler: function * (ctx, opts) {
// `ctx` is equal to `this` and `app`
// `opts` is current options object
// passed to `{%= name %}`
ctx.body = yield this.request.text(opts.textLimit)
}
}))
app.use(function * showBody () {
// `this.body` is text
console.log(this.body)
})
```


## Note about advanced `querystring` parsing
Because this middleware is fully based and integrated with [koa-body-parsers][], by default it uses Node's built-in module for that thing [querystring](https://nodejs.org/api/querystring.html). So if you have some issues with forms, think to add custom querystring module like [qs][] to `options.querystring` or `app.querystring`. Related to this is [issue #45](https://github.com/tunnckoCore/koa-better-body/issues/45).

**Example**

```js
const app = require('koa')()
const body = require('koa-better-body')

app.use(body({
multipart: false
querystring: require('qs')
}))
```

It's intentional that it's not included in the deps by default. In `v2` it was also working by passing it to `app.querystring`, because [koa-body-parsers][] works [that way (index.js#L53)](https://github.com/koajs/body-parsers/blob/master/index.js#L53).


## Note about `strict` mode
We are trying to follow standards. :cat2:

You can pass `strict:false`, but see [IETF HTTP/1.1 Message Semantics: Section 6.1](https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-19#section-6.1) to understand why we stay to _"strict mode"_ by default. 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. Last two tests at [test/options.js](./test/options.js) are showing usage on non-strict and strict mode.


{% if (verb.related && verb.related.list && verb.related.list.length) { %}
## Related
You might also be interested in these packages:
{%= related(verb.related.list, {words: 14}) %}
{% } %}

## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/{%= repository %}/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.

### Contributing Recipes
Recipes are just different use cases, written in form of README in human language. Showing some "Pro Tips" and tricks, answering common questions and so on. They look like [tests](./test.js), but in more readable and understandable way for humans - mostly for beginners that not reads or understand enough the README or API and tests.

- They are in form of folders in the root [`recipes/`](./recipes) folder: for example `recipes/[short-meaningful-recipe-name]/`.
- In recipe folder should exist `README.md` file: see [recipes/multipart/README.md](./recipes/multipart/README.md).
- The examples from the recipe README.md should also exist as separate `.js` files.
- Examples in recipe folder also should be working and actual.

It would be great if you follow these steps when you want to _fix, update or create_ a recipes. :sunglasses:

- Title for recipe idea should start with `[recipe]`: for example`[recipe] my awesome recipe`
- Title for new recipe (PR) should also start with `[recipe]`.
- Titles of Pull Requests or Issues for fixing/updating some existing recipes should start with `[recipe-fix]`.

It will help a lot, thanks in advance! :yum:

## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]

[![{%= author.username %}.tk][author-www-img]][author-www-url] [![keybase {%= author.username %}][keybase-img]][keybase-url] [![{%= author.username %} npm][author-npm-img]][author-npm-url] [![{%= author.username %} twitter][author-twitter-img]][author-twitter-url] [![{%= author.username %} github][author-github-img]][author-github-url]

{%= reflinks(verb.reflinks) %}

[npmjs-url]: https://www.npmjs.com/package/{%= name %}
[npmjs-img]: https://img.shields.io/npm/v/{%= name %}.svg?label={%= name %}

[license-url]: https://github.com/{%= repository %}/blob/master/LICENSE
[license-img]: https://img.shields.io/npm/l/{%= name %}.svg

[downloads-url]: https://www.npmjs.com/package/{%= name %}
[downloads-img]: https://img.shields.io/npm/dm/{%= name %}.svg


[codeclimate-url]: https://codeclimate.com/github/{%= repository %}
[codeclimate-img]: https://img.shields.io/codeclimate/github/{%= repository %}.svg

[travis-url]: https://travis-ci.org/{%= repository %}
[travis-img]: https://img.shields.io/travis/{%= repository %}/master.svg

[coveralls-url]: https://coveralls.io/r/{%= repository %}
[coveralls-img]: https://img.shields.io/coveralls/{%= repository %}.svg

[david-url]: https://david-dm.org/{%= repository %}
[david-img]: https://img.shields.io/david/{%= repository %}.svg

[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg


[author-www-url]: http://www.{%= author.username.toLowerCase() %}.tk
[author-www-img]: https://img.shields.io/badge/www-{%= author.username.toLowerCase() %}.tk-fe7d37.svg

[keybase-url]: https://keybase.io/{%= author.username.toLowerCase() %}
[keybase-img]: https://img.shields.io/badge/keybase-{%= author.username.toLowerCase() %}-8a7967.svg

[author-npm-url]: https://www.npmjs.com/~{%= author.username.toLowerCase() %}
[author-npm-img]: https://img.shields.io/badge/npm-~{%= author.username.toLowerCase() %}-cb3837.svg

[author-twitter-url]: https://twitter.com/{%= author.username %}
[author-twitter-img]: https://img.shields.io/badge/twitter-@{%= author.username %}-55acee.svg

[author-github-url]: https://github.com/{%= author.username %}
[author-github-img]: https://img.shields.io/badge/github-@{%= author.username %}-4183c4.svg

[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg

[new-message-url]: https://github.com/{%= author.username %}/ama
[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg
Loading