koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.11k stars 3.22k forks source link

Initialize context.state sooner #1732

Open krisstern opened 1 year ago

krisstern commented 1 year ago

Fixes #1646

Description

Allow context creation an overridable Koa option.

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Base: 99.61% // Head: 99.61% // No change to project coverage :thumbsup:

Coverage data is based on head (3a3f9b3) compared to base (bec13ec). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1732 +/- ## ======================================= Coverage 99.61% 99.61% ======================================= Files 5 5 Lines 521 521 Branches 145 145 ======================================= Hits 519 519 Misses 2 2 ``` | [Impacted Files](https://codecov.io/gh/koajs/koa/pull/1732?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs) | Coverage Δ | | |---|---|---| | [lib/context.js](https://codecov.io/gh/koajs/koa/pull/1732?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs#diff-bGliL2NvbnRleHQuanM=) | `100.00% <ø> (ø)` | | | [lib/application.js](https://codecov.io/gh/koajs/koa/pull/1732?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs#diff-bGliL2FwcGxpY2F0aW9uLmpz) | `98.43% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=koajs)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

krisstern commented 1 year ago

Change looks fine for what it does.

Consider asserting this in context state test.

Hi @antaranyan Sure, I have just modified the exisitng test for context > state.

jonathanong commented 3 weeks ago

what's the point of this? why not just make a middleware that does what you want?

dwhieb commented 3 weeks ago

@jonathanong https://github.com/koajs/koa/issues/1646