-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
39 lines (30 loc) · 1.29 KB
/
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
module.exports = function (App, options) {
var path = require('path');
function ServiceProvider() {
var _this = this;
this.package = {
name: 'mcmsNodeImageUploads',
options: options || {},
settings : {},
baseDir : App.Config.baseDir || options.baseDir || path.resolve('./')
};
//Load the config
if (typeof options == 'object' && options.config){
//Acceptable types is file,property,object
//file should be absolute path
if (options.type == 'file'){
this.package.settings = require(options.name);
} else if (options.type == 'property'){
this.package.settings = App.Config[options.name];
} else {
this.package.settings = options.value;//assume object
}
}
App.Services[this.package.name] = this.package.Services = App.helpersLoader.loadServices(__dirname + '/Services', null, this.package);
App.Workers[this.package.name] = this.package.Workers = App.helpersLoader.loadDirContents(__dirname + '/Workers', null, this.package);
App.on('booted',function () {
//Everything is loaded, do something fancy
});
}
return new ServiceProvider();
};