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. |
|
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