-
f858724Thanks @TheDadi! - Drop support for Node.js 18 and 20, both of which are past end-of-life (Node 18 EOL April 2025, Node 20 EOL April 2026).The minimum supported version is now Node.js 22. CI is tested against Node 22 (Maintenance LTS), 24 (Active LTS), and 26 (Current).
If you are on Node 18 or 20, upgrade to Node 22+ before updating
koa-body. No source-level API changes accompany this bump — it reflects the supported runtime floor only.
-
9b3b5b6Thanks @TheDadi! - Add configurable body-type matchers:jsonTypes,urlencodedTypes,textTypes, andmultipartTypes.These options let callers customize which
Content-Typevalues are parsed as which body kind, without patching the middleware internals. Each accepts an array of types passed directly to Koa'sctx.is(...), so the standard mime patterns (e.g.urlencoded,multipart,text/*,application/vnd.custom+json) all work.Defaults preserve the previous behavior:
jsonTypes:application/json,application/json-patch+json,application/vnd.api+json,application/csp-report,application/reports+jsonurlencodedTypes:urlencodedtextTypes:text/*multipartTypes:multipart
Example — parse a vendor JSON type and a custom multipart type:
app.use( koaBody({ jsonTypes: ["application/json", "application/vnd.custom+json"], multipart: true, multipartTypes: ["multipart", "application/x-custom-multipart"], }) );
-
#239
e59b8ceThanks @TheDadi! - chore: introduce@biomejs/biomeas linter and formatter instead ofprettierchore: introduce@changesets/clito automate publish and changelog chore: introduce GitHub actions for publishing to npm chore: introduce GitHub actions for preview publish usingpkg-pr-newchore: replacemochawithnode:testchore: updated all dependencies to latest chore: updated dev dependencykoa-routerto use@koa/routerinstead chore: introducetshyand@arethetypeswrong/clito have esm and commonjs exports and verification that types and exports are compatible with different module resolutions (fixes: #233) chore: introducepnpmas package-managerrefactor: use
ctx.request.rawBodyinstead ofctx.request.body[symbolUnparsed]for unparsed body ifincludeUnparsedis set refactor:ctx.request.rawBodyis also set on content-typetext/*ifincludeUnparsedis set refactor: if given method is not inparsedMethodsdo not patch koa and node with empty object anymore (fixes: #238) refactor: changed type ofctx.req.bodyandctx.request.bodyfromanyto{ [key: string]: unknown } | stringfeat: allow to override formidable
onPartsee https://github.com/node-formidable/formidable#formonpart (fixes: #172)docs: updated README.md to reflect changes docs: reworked examples to use
typescript
- rewrite in TypeScript (thanks @TheDadi)
- removed the deprecated strict option
- add "application/reports+json" to allowed types (#204)
- test against Node.js 14+
Mistakenly republished v4.2.0. See #207.
- support all text content types (#179)
- adds TypeScript integration testing (#177)
- removes testing against EOL Node.js verions
Reverted changes introduced in 4.1.2. Now 4.1.3 is effectively the same as 4.1.1.
Bad TypeScript definition file change (#173). Do not use this version.
- adds support for JSON Patch, JSON API and CSP report out of the box:
- application/json-patch+json (https://tools.ietf.org/html/rfc6902)
- application/vnd.api+json (https://jsonapi.org/)
- application/csp-report (https://www.w3.org/TR/CSP2/#violation-reports)
- adds
parsedMethodsoption to specify which request methods will be parsed - deprecates
strictoption, which will be removed in koa-body 5.0.0
Migration from prior 4.x.x versions is strightforward.
- If you used
strict: true, simply remove this option. The new defaults will behave the same way. - If you used
strict: false, setparsedMethodsto the set of methods you would like to parse. For example,parsedMethods: ['GET', 'POST', 'PUT', 'PATCH']
- mutliple type definition updates
- adds
includeUnparsedoption to get raw body
To address a potential security vulnerability:
- The
filesproperty has been moved toctx.request.files. In prior versions,fileswas a property ofctx.request.body. - The
fieldsproperty is flatten (merged) intoctx.request.body. In prior versions,fieldswas a property ofctx.request.body.
If you do not use multipart uploads, no changes to your code need to be made.
Versions 1 and 2 of koa-body are deprecated and replaced with versions 3 and 4, respectively.