Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改启动文件app.js、agent.js,将app.beforeStart替换为新版的启动自定义 #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 14 additions & 3 deletions agent.js
Original file line number Diff line number Diff line change
@@ -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;
16 changes: 13 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
'use strict';

module.exports = app => {
require('./lib/loader')(app);
};
class AppBootHook {

constructor(app) {
this.app = app;
}

async didLoad() {
// 请将你的插件项目中 app.beforeStart 中的代码置于此处。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉注释

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要把 loader 改造成 async function,否则你这里的变更有问题

await require('./lib/loader')(this.app);
}

}

module.exports = AppBootHook;
6 changes: 3 additions & 3 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down