Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add request and response utils #15

Merged
merged 11 commits into from
Dec 12, 2020
Merged

feat: add request and response utils #15

merged 11 commits into from
Dec 12, 2020

Conversation

farnabaz
Copy link
Contributor

This PR

  • creates useQuery util to parse the query params of request.
  • creates useBody util to parse raw and JSON payload of the request.
  • Modify createError util to support runtime error to support runtime errors like validation errors.

src/app.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
@pi0 pi0 merged commit 648e9b9 into unjs:main Dec 12, 2020
@Atinux
Copy link
Member

Atinux commented Dec 13, 2020

Would it be possible to open another PR for documenting them @farnabaz ?

@Atinux
Copy link
Member

Atinux commented Dec 13, 2020

Also, shouldn't we rename them to getBody(req) that actually use destr by default and having getRawBody() instead?

@pi0
Copy link
Member

pi0 commented Dec 13, 2020

Usage of body might be ambiguous for different responses but might rename useBodyJSON to useJSON for shorter name if it is better :)

Update: More thinking seems reasonable DX wise 😁

@farnabaz
Copy link
Contributor Author

@Atinux I'll create PR for docs.
What about creating a docs project?

@Atinux
Copy link
Member

Atinux commented Dec 14, 2020

I think README is enough for now, cc @pi0

@pi0
Copy link
Member

pi0 commented Dec 14, 2020

Yeah. H2 is pretty much an experimental project now and i don't want to put energy on docs for in development utils. We may later on benefit jsdocs

@danielroe
Copy link
Member

@pi0 It may be worth starting off with jsdoc comments as these can be more easily kept up-to-date with changes to API? I am happy to do that if you agree.

@pi0
Copy link
Member

pi0 commented Dec 14, 2020

JSDocs seems better that would be nice if you are up to add them :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants