-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
41 lines (33 loc) · 877 Bytes
/
index.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
'use strict'
const _ = require('lodash')
const Trailpack = require('trailpack')
module.exports = class BootStrap extends Trailpack {
/**
* Check there a config.bootstrap file that export a function
*/
validate () {
if (!this.app.config.bootstrap) {
return Promise.reject(new Error('There not config.bootstrap !'))
}
if (!_.isFunction(this.app.config.bootstrap)) {
return Promise.reject(new Error('config.bootstrap is not a function !'))
}
return Promise.resolve()
}
/**
* Listen trails:ready event and call bootstrap function
*/
initialize () {
this.app.on('trails:ready', () => {
this.app.config.bootstrap(this.app)
})
return Promise.resolve()
}
constructor (app) {
super(app, {
config: require('./config'),
api: require('./api'),
pkg: require('./package')
})
}
}