feat(context-storage): Add optional tryGetContext helper to context-storage middleware
introduce getContextIfAny, which returns the stored context or undefined without throwing make the existing getContext delegate to the softer helper so behavior stays unchanged when no context exists expand the context-storage tests to cover both success and missing-context scenarios for the new helper
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 91.49%. Comparing base (342ff3b) to head (15cde5d).
Additional details and impacted files
@@ Coverage Diff @@
## next #4539 +/- ##
==========================================
- Coverage 91.52% 91.49% -0.03%
==========================================
Files 172 172
Lines 11221 11233 +12
Branches 3255 3258 +3
==========================================
+ Hits 10270 10278 +8
- Misses 950 954 +4
Partials 1 1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
This PR will resolve #4536.
@AyushCoder9 Thank you for the PR!
Hi @elibarzilay! What do you think of this PR? I think good.
@AyushCoder9 Thank you for the PR!
Hi @elibarzilay! What do you think of this PR? I think good.
LGTM either way -- I specifically avoided thinking too much about a good name, to leave it up to people who might know the codebase better :)
@AyushCoder9 Thank you for the PR!
Hi @elibarzilay! What do you think of this PR? I think good.
LGTM either way -- I specifically avoided thinking too much about a good name, to leave it up to people who might know the codebase better :)
@elibarzilay are you merging this pr ? Tell me if I need to change something !!
I'm just the person who made the feature request, I'm not a regular contributor...
(Also, I'm guessing that it would be good to get a blessing from @marceloverdijk since he wrote the code.)
I'm just the person who made the feature request, I'm not a regular contributor...
(Also, I'm guessing that it would be good to get a blessing from @marceloverdijk since he wrote the code.)
@marceloverdijk check if this pr is good enough
👍 I think it looks good (and a nice addition)
👍 I think it looks good (and a nice addition)
glad to here that @marceloverdijk merge it if you liked it, would be an honour !!
Hi @AyushCoder9
Can you handle the comment https://github.com/honojs/hono/pull/4539#discussion_r2573092807?
If you don't react to it, we can't merge this.
Hi @AyushCoder9
Can you handle the comment #4539 (comment)?
If you don't react to it, we can't merge this.
@yusukebe I've updated the PR to rename getContextIfAny to tryGetContext.
@AyushCoder9
Thank you!! We are planning to include this change in the next minor version. So, I'll merge this later!
Thanks! -- I closed #4536.