app.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const path = require('path');
// module.exports = app => {
// app.beforeStart(async function() {
// // 应用会等待这个函数执行完成才启动
// // await app.model.sync({ force: true }); // 开发环境使用
// await app.model.sync({});
// });
class AppBootHook {
constructor(app) {
this.app = app;
this.helper = app.helper;
}
async configWillLoad() {
console.log(`
◆ 项目:广联赛讯历史保单数据服务
◆ 语言:Javascript
◆ 框架:Node.js + Egg.js + MySql
◆ 版本控制: git-github
◆ 代码风格:eslint-standard
◆ 编辑器: VSCode
◆ 数据库: mysql
◆ 服务器端脚本: Node.js
◆ author: limin
`)
}
async didReady() {
const ctx = await this.app.createAnonymousContext();
console.log(' ◆ 加载校验规则\r\n')
console.log('\r\n ◆ 应用启动成功!\r\n')
await this._init_user_validations_(ctx);
}
async _init_user_validations_() {
const directory = path.join(this.app.config.baseDir, './app/validate');
this.app.loader.loadToApp(directory, 'validate');
}
}
module.exports = AppBootHook;