Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ const fastifyAutoload = async function autoload (fastify, options) {
}

async function loadPlugins ({ pluginTree, options, opts, fastify }) {
const nodes = []
const pluginsMeta = {}
for (const key in pluginTree) {
const node = {
...pluginTree[key],
pluginsMeta: {},
pluginsMeta,
hooksMeta: {}
}
nodes.push(node)

await Promise.all(node.plugins.map(({ file, type, prefix }) => {
return loadPlugin({ file, type, directoryPrefix: prefix, options: opts, log: fastify.log })
Expand All @@ -55,7 +58,9 @@ async function loadPlugins ({ pluginTree, options, opts, fastify }) {
throw enrichError(err)
})
}))
}

for (const node of nodes) {
registerNode(node, fastify)
}
}
Expand Down