-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add fastify-loader to Ecosystem.md #1154
Conversation
How is this different than using https://github.com/fastify/fastify-autoload ? |
@cemremengu You don't need to write module.exports = function (fastify, opts, next) { The fastify instance gets injected. Edit: |
I'm kind of -1 into publicizing modules that monkeypatch the Node.js loader. I would discourage people to use this: https://github.com/TheNoim/fastify-loader/blob/master/inject.js. Also, exporting a function and passing in the fastify instance ensures that multiple copies of the same fastify app could get started (in tests, for examples). |
You can. But everyone propably should decide on their own.
Yes this is right. But in most cases, this isn't needed. You can see this more like an: I want to make a quick webserver for a small project with as less stumbling stones as possible. |
This is needed in most cases, as it will prevent writing effective unit tests. It is possible to achieve something very similar with the use of the |
Pff.. Untis test, my most hated thing. :P Edit: You can pass multiple fastify instances. You can change the instance name.
This was the first thing I tried. But if you provide a context, it gets sandboxed. This prevents to apply changes made to the fastify instance. The only alternative would be eval. But eval has access to the lcoal scope. Another alternative is vm2. |
@mcollina Updated the module. Replace this "hacky" method with vm2. |
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.
LGTM
Good work! It would be fantastic to add a unit test to load 2 fastify apps in the same process ;). |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Checklist
Link: fastify-loader