-
-
Notifications
You must be signed in to change notification settings - Fork 681
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: introduce Plugins API, fix tests #545
Conversation
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Not bad.
|
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding me as a contributor
Sure, of course ; ) trying to sync the bot and GH actions... ;d @all-contributors please add @tunnckoCore for idea and doc |
close #407 Co-authored-by: Claudio Poli <masterkain@gmail.com> Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Happy birthday to me 🎉 Available through |
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
@GrosSacASac , it's generally ready. There are two test suites - one is the old, second is with Jest (the After merging this a lot will be closed too, so v2 is really near, just need to add a few easy fixes and features like #154 and #153 I hope you are okay with the ton of stuff updates on the master and this PR. |
The only thing I'm wondering is when and why the performance dropped to 1500mb/sec, it was up to 2500mb/sec for some time. And I didn't touched the multipart parser... Hm... 🤔 |
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
test/unit/test-incoming-form.js
)options
in constructorthis.globalOptions = { ...options };
Why?
Better separation. Easier future testing. More extensible so there can be developed third-party plugins (for example more advanced QueryString parser). We now can unit test each separate plugin/parser.
Plugins API
add
form.use(plugin: Plugin)
methodA method that allows you to extend the Formidable library. By default we include 4 plugins,
which esentially are adapters to plug the different built-in parsers.
The plugins added by this method are always enabled.
See src/plugins/ for more detailed look on default plugins.
The
plugin
param has such signature:The architecture is simple. The
plugin
is a function that is passed withthe Formidable instance (the
form
across the README examples) and the options.Note: the plugin function's
this
context is also the same instance.Important to note, is that inside plugin
this.options
,self.options
andoptions
MAY or MAY NOT be the same. General best practice is to always use the
this
, so you canlater test your plugin independently and more easily.
If you want to disable some parsing capabilities of Formidable, you can disable the plugin
which corresponds to the parser. For example, if you want to disable multipart parsing
(so the src/parsers/Multipart.js which is used in src/plugins/multipart.js), then you can remove it from
the
options.enabledPlugins
, like soBe aware that the order MAY be important too. The names corresponds 1:1
to files in src/plugins/ folder.
Pull requests for new built-in plugins MAY be accepted - for example,
more advanced querystring parser. Add your plugin as a new file
in
src/plugins/
folder (lowercased) and follow how the other plugins are made.