@fastify/autoload
Advanced tools
Comparing version 5.9.0 to 5.10.0
19
index.js
@@ -29,7 +29,2 @@ 'use strict' | ||
let rootPrefix = options.options?.prefix ?? '' | ||
// when prefix is provided /prefix/ format | ||
// it is not good for concat, since most folder prefix start with / | ||
if (rootPrefix[rootPrefix.length - 1] === '/') rootPrefix = rootPrefix.slice(0, -1) | ||
await Promise.all(pluginArray.map(({ file, type, prefix }) => { | ||
@@ -90,20 +85,12 @@ return loadPlugin({ file, type, directoryPrefix: prefix, options: opts, log: fastify.log }) | ||
} | ||
registerAllPlugins(app, pluginFiles, true) | ||
registerAllPlugins(app, pluginFiles) | ||
} | ||
fastify.register(composedPlugin, { | ||
prefix: rootPrefix + replaceRouteParamPattern(prefix) | ||
}) | ||
fastify.register(composedPlugin) | ||
} | ||
} | ||
function registerAllPlugins (app, pluginFiles, composed = false) { | ||
function registerAllPlugins (app, pluginFiles) { | ||
for (const pluginFile of pluginFiles) { | ||
// find plugins for this prefix, based on filename stored in registerPlugins() | ||
const plugin = metas.find((i) => i.filename === pluginFile.file) | ||
if (composed) { | ||
plugin.options.prefix = undefined | ||
} | ||
// register plugins at fastify level | ||
@@ -110,0 +97,0 @@ if (plugin) registerPlugin(app, plugin, pluginsMeta) |
{ | ||
"name": "@fastify/autoload", | ||
"version": "5.9.0", | ||
"version": "5.10.0", | ||
"description": "Require all plugins in a directory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,3 +15,4 @@ 'use strict' | ||
autoHooks: true, | ||
cascadeHooks: true | ||
cascadeHooks: true, | ||
routeParams: true | ||
}) | ||
@@ -18,0 +19,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
136649
149156
266
4107