feat: add basic auth util and middleware#998
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #998 +/- ##
==========================================
+ Coverage 77.83% 83.41% +5.58%
==========================================
Files 47 36 -11
Lines 4286 2647 -1639
Branches 611 681 +70
==========================================
- Hits 3336 2208 -1128
+ Misses 933 437 -496
+ Partials 17 2 -15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I think it would be better if we expose a H3 utils tend to be explicit for usage (called exactly where they need to) |
|
Yeah I can rework this. To confirm my understanding, is this the API you're expecting? defineEventHandler({
onBeforeResponse: (event) => requireBasicAuth(event, {username: 'hello', password: 'world' }),
handler: (_event) => {
return { message: "⚡️ Tadaa!" };
}
})
defineEventHandler((event) => {
requireBasicAuth(event, {username: 'hello', password: 'world' })
return { message: "⚡️ Tadaa!" };
})In this scenario, |
348028f to
a449d79
Compare
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thanks for the initial work on this! I updated PR with |
Resolves #551
Port of #826 to the main (v2) branch