-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (32 loc) · 892 Bytes
/
app.js
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
40
41
42
'use strict'
const path = require('path')
class AppBootHook {
constructor (app) {
this.app = app
}
configWillLoad () {
}
async didLoad () {
const dir = path.join(this.app.config.baseDir, 'app/mongo');
const pro = this.app.mongoose.Model;
this.app.loader.loadToApp(dir, 'mongo', {
inject: this.app,
caseStyle: 'upper',
filter(model) {
return typeof model === 'function' && model.prototype instanceof pro;
},
});
}
async willReady () {
// 请将你的应用项目中 app.beforeStart 中的代码置于此处。
if (Object.keys(this.app.model).length > 0 && (this.app.config.env === 'local' || this.app.config.env === 'unittest')) {
// await this.app.model.sync()
}
}
async didReady () {
// require('./config/seed')(this.app)
}
async serverDidReady () {
}
}
module.exports = AppBootHook