-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Refactoring the component #383
Comments
I dont see the maintenance problem. The code is actually of very high quality. Also it is "only" about 500 LOC. The issue is that the problem it tries to solve is complex itself. That results in not seeing every "edge" case. |
Perhaps I should have expressed myself less assertively. Maybe you can elaborate what you were thinking by saying this @climba03003:
|
The main problem is that the current information split into two array. Lines 26 to 27 in 1370697
Sometimes the information is not able to find inside some function. For what I propose is that we should define the works into 3 clear steps.
In this case we can always change the function inside step 2. to provide different behavior instead of looking around different function and gather necessary information in different place. In step 2, the tree building output should be something like, interface Node {
prefix: string
pluginDir: string
func: FastifyPluginAsync
hooks: FastifyPluginAsync[]
children: Node[] // it should be used in some plugin options only
}
// most of the time each prefix is using only one func
type PluginTree = Node[] |
I agree that hooks should be composed to plugin tree before registration step.
Btw, do you think we should allow export const autoConfig = { name: 'y' }
export const autoPrefix = "/prefixed"; I am not sure that it's a good idea but some people want to use them there, I saw this in a reproduction issue repo. If we don't maybe we should throw a clean error to educate users when they try to export such variables. |
It is not a good idea to permit hooks having different config or prefix than the |
Prerequisites
Issue
The code is becoming increasingly difficult to maintain, I think it deserves a redesign as suggested here and here.
I'd like to know if you have any suggestions before proceeding, we could also consider proceeding step by step.
The text was updated successfully, but these errors were encountered: