Closed vlev1n closed 7 months ago
It is the very first point of the release notes listed as:
feat: align request body better to Fetch API (bb996fe)
BREAKING CHANGE Previous versions of oak had a request body API that was fairly convoluted as oak evolved from the early days of Deno where there wasn't a built in APIs for handling HTTP requests. The Fetch API
Request
andResponse
have become the standard almost everywhere and make it easy to get ahold of a request body in many forms.Inspired by this the
ctx.request.body
aligns to this API for the most part, but also still retains some of the advantages that oak provided like providing actx.request.body.type
to help figure out what sort of body you are looking at as well as support forctx.request.body.form()
.This also leverages native Fetch API where possible which resolved a lot of issues with decoding multi-part forms. This does mean files that are uploaded to oak become web standard
File
s that are entries inFormData
. This meansmultipart.ts
has been removed from oak and the
Inline API documentation was updated as well.
The README needs to be updated.
(Also, the release notes/change log list the other breaking changes in 13)
Thank you for pointing out the update in the CHANGELOG.md. I apologize for missing that in my initial review. The only change needed is README to ensure it's immediately visible to new users (like me 😂).
Thanks again for your quick response and for maintaining this project!
Now we will need to refactor our previous projects because of this update
Now we will need to refactor our previous projects because of this update
Yeah, that is why breaking changes are breaking changes, but previous versions are still available. 🤯
Fixed in 43de84ab33bcee0d85f0a734a1417ec9c6a6ab91
I recently upgraded to oak version 13 and encountered a breaking change in the way
request.body
is accessed, which isn't documented in the current release notes or documentation. Below are minimal examples showing the usage in versions 12 and 13:In oak v13, the previous method of accessing the request body results in a
Type 'Body' has no call signatures
error. I was able to find the correct code by examining the source code, but this change is not reflected in the documentation.I'm opening this issue for awareness and reference for others who might encounter the same issue. It would be helpful if the documentation could be updated to reflect this and any other breaking changes in v13.
Thank you for your hard work on this project!