forked from inProgress-team/BlueStormJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (56 loc) · 1.74 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var async = require('async'),
mongoose = require('mongoose');
var logger = require(__dirname+'/src/logger/logger'),
server = require(__dirname+'/src/server/server'),
cli = require(__dirname+'/src/cli'),
arborescence = require(__dirname+'/src/arborescence'),
upload = require(__dirname + '/src/upload/upload');
module.exports = {
cli: cli,
server: server,
logger: logger,
upload: upload,
db: function(callback) {
require(__dirname + '/db')(function(err, res) {
if (err)
return callback(err);
return callback(res.db);
});
},
mongo: function(callback) {
require(__dirname + '/mongo')(callback);
},
user: require(__dirname + '/src/server/user/models/user'),
userSchema: function(fields) {
if (typeof fields == 'function') {
callback = fields;
fields = null;
}
var Schema = mongoose.Schema;
var defaultsFields = {
"email": String,
"password": String,
"role": String,
"activated": {type: Boolean, default: false}
};
if (fields) {
for (var i in fields) {
if (fields.hasOwnProperty(i)) {
defaultsFields[i] = fields[i];
}
}
}
return new Schema(defaultsFields);
},
mongoose: mongoose,
mailer: require(__dirname + '/src/email/mailer')
};
require(__dirname + '/src/db/returnmongoose');
require(__dirname + '/db')(function(err, res) {
if (res.type == 'mongoose') {
arborescence.getRequiredFiles('models', function (files) {
arborescence.loadFiles(files, null, function () {
});
});
}
});