Skip to content

Commit

Permalink
fix: not allowed empty routers in plugin
Browse files Browse the repository at this point in the history
# Problem
- When create custom router of plugin,
routers(in config) may be empty
# Solution
- Use `lodash get` to default to empty Array
when empty routers
  • Loading branch information
Chinlinlee committed Jan 6, 2023
1 parent 6248724 commit 2fe1fc4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/plugin.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ class PluginGroup {
*/
convertToLocalPlugins(plugin) {
let localPlugins = [];
for(let router of plugin.options.routers) {
let routers = _.get(plugin.options, "routers", []);

for(let router of routers) {
let localPlugin = new LocalPlugin(router.path, router.method, plugin.preProcessGroup, plugin.postProcessGroup);
localPlugins.push(localPlugin);
}
Expand Down

0 comments on commit 2fe1fc4

Please sign in to comment.