diff --git a/agent.js b/agent.js index 92b0d38..4551bfb 100644 --- a/agent.js +++ b/agent.js @@ -1,5 +1,16 @@ 'use strict'; -module.exports = agent => { - require('./lib/loader')(agent); -}; +class AgentBootHook { + + constructor(agent) { + this.agent = agent; + } + + async didLoad() { + // 请将你的插件项目中 app.beforeStart 中的代码置于此处。 + await require('./lib/loader')(this.agent); + } + +} + +module.exports = AgentBootHook; diff --git a/app.js b/app.js index 1d56502..8a52604 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,16 @@ 'use strict'; -module.exports = app => { - require('./lib/loader')(app); -}; +class AppBootHook { + constructor(app) { + this.app = app; + } + + async didLoad() { + // 请将你的插件项目中 app.beforeStart 中的代码置于此处。 + await require('./lib/loader')(this.app); + } + +} + +module.exports = AppBootHook; \ No newline at end of file diff --git a/lib/loader.js b/lib/loader.js index 22eba2f..990ae50 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -36,9 +36,9 @@ module.exports = app => { }); } - app.beforeStart(async () => { - await Promise.all(databases.map(database => authenticate(database))); - }); + // app.beforeStart(async () => { + return Promise.all(databases.map(database => authenticate(database))); + // }); /** * load databse to app[config.delegate