Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = async service => {
service.plugins = Array.isArray(service.config.plugins)
? service.config.plugins.map(normalize).filter(plugin => !!plugin.use)
: []
for (let i = 0, l = service.plugins.length; i < l; i++) {
const plugin = service.plugins[i]
const use = plugin.use.replace(internalRE, '../')
plugin.uid = uid(use, i)
plugin.api = new PluginAPI(service, plugin)
try {
const func = require(use)
const options = defaultsDeep(plugin.options, func.defaultOptions)
await func(plugin.api, options)
} catch (err) {}
}
}