-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
53 lines (45 loc) · 1.7 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
if (process.env['NODE_ENV'] == 'test') {
process.env['USE_MOCKS'] = true;
}
module.exports = function (sails) {
var loader = require("sails-util-mvcsloader")(sails);
var responses = require("./lib/responses")(sails);
var discovery = require("./lib/discovery.js");
/**
* inject the policies and config first before returning this next link in the hook startup chain
* need to be in place before sails binding
*/
sails.log.info('Loading Blade Policies and Configuration');
loader.injectAll({
policies : __dirname + '/api/policies',
config : __dirname + '/config'
});
return {
initialize: function(cb) {
sails.log.info('Loading Blade Standard Responses');
responses.initialize(function(err) {
if (err) {
return cb(err);
}
sails.log.info('Loading Blade Controllers, Models, and Services');
loader.injectAll({
controllers: __dirname + '/api/controllers',
models : __dirname + '/api/models',
services : __dirname + '/api/services'
}, function (err) {
if (err) {
return cb(err);
}
//initialize discovery
discovery.initialize(sails);
if (sails.config.authentication) {
sails.on('router:after', sails.config.authentication.bindRoutes);
}
return cb();
});
})
},
loadModules: responses.loadModules,
routes: responses.routes
}
};