Add option to programmatically disable plugin#11
Add option to programmatically disable plugin#11Abion47 wants to merge 1 commit intotobias-kaerst-software:mainfrom
Conversation
📝 WalkthroughWalkthroughThe changes introduce an optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/index.ts (1)
6-9: Consider including theaotoption for consistency.The disabled path includes
seedbut omitsaot, while the enabled path (lines 11-14) includes both. For consistency and to avoid potential confusion, consider including theaotoption here as well.♻️ Proposed change for consistency
if (options.enabled === false) { return new Elysia({ name: 'elysia-helmet', seed: options.seed ?? '', + aot: options.aot ?? true, }); }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/helmet.tssrc/index.ts
🔇 Additional comments (2)
src/helmet.ts (1)
46-46: LGTM!The optional
enabledproperty is correctly typed and positioned. The property provides a clean, idiomatic way to disable the plugin programmatically.src/index.ts (1)
5-10: Correct implementation of the disable feature.The explicit
=== falsecheck correctly handles all cases:
undefinedortrue→ plugin enabled (default behavior maintained)false→ plugin disabled (new behavior)This approach properly maintains backward compatibility while adding the new disable functionality.
The idiomatic way to disable plugins in Elysia is with an
enabledproperty on the configuration object. This will allow an easy and idiomatic way to programmatically disable the plugin, such as in non-production environments or when the plugin is misbehaving.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.