正在显示
6 个修改的文件
包含
90 行增加
和
19 行删除
etc/init/05-server.js
0 → 100644
... | ... | @@ -11,18 +11,8 @@ IoC.use('igloo', require('./igloo')); |
11 | 11 | |
12 | 12 | |
13 | 13 | var app = bootable(express()); |
14 | +app.phase(bootable.di.initializers()); | |
14 | 15 | |
15 | -// app.pushPhase = function (phase) { | |
16 | -// new Promise(function (resolve, reject) { | |
17 | -// phase(resolve, reject) | |
18 | -// }).then(function (data) { | |
19 | -// app.phase(bootable.di.initializers()); | |
20 | -// app.phase(bootable.di.routes('./routes')); | |
21 | -// IoC.create('igloo/server').then(function (server) { | |
22 | -// app.phase(server); | |
23 | -// }); | |
24 | -// }); | |
25 | -// }; | |
26 | 16 | |
27 | 17 | var workaiExpress = { |
28 | 18 | 'app': app, | ... | ... |
routes/auth.js
0 → 100644
1 | +var express = require('express'); | |
2 | + | |
3 | +exports = module.exports = function (settings) { | |
4 | + var app = this; | |
5 | + var router = express.Router(); | |
6 | + router.get( | |
7 | + '/', | |
8 | + function (req, res, next) { | |
9 | + res.send({ '/': '1' }); | |
10 | + } | |
11 | + ); | |
12 | + router.get( | |
13 | + '/offer/:requestId', | |
14 | + function (req, res, next) { | |
15 | + res.send({ '/offer/:requestId': '1' }); | |
16 | + } | |
17 | + ); | |
18 | + | |
19 | + router.get( | |
20 | + '/downloadApp', | |
21 | + function (req, res, next) { | |
22 | + res.send({ 'downloadApp': '1' }); | |
23 | + } | |
24 | + ); | |
25 | + | |
26 | + router.get( | |
27 | + '/info/policy', | |
28 | + function (req, res, next) { | |
29 | + res.send({ '/info/policy': '1' }); | |
30 | + } | |
31 | + ); | |
32 | + | |
33 | + router.get( | |
34 | + '/payRoll', | |
35 | + function (req, res, next) { | |
36 | + res.send({ '/payRoll': '1' }); | |
37 | + } | |
38 | + ); | |
39 | + | |
40 | + router.get( | |
41 | + '/recharge', | |
42 | + function (req, res, next) { | |
43 | + res.send({ '/recharge': '1' }); | |
44 | + } | |
45 | + ); | |
46 | + | |
47 | + app.use('/', router); | |
48 | +}; | |
49 | + | |
50 | +exports['@require'] = ['igloo/settings']; | |
51 | +exports['@singleton'] = true; | ... | ... |
routes/index.js
0 → 100644
1 | + | |
2 | +// app - routes | |
3 | +var workaiExpress = require('../index'); | |
4 | +var app = workaiExpress.app; | |
5 | +var IoC = workaiExpress.IoC; | |
6 | +var bootable = workaiExpress.bootable; | |
7 | + | |
8 | +exports = module.exports = function (settings) { | |
9 | + | |
10 | + var app = this; | |
11 | + //auth | |
12 | + app.phase(bootable.di.routes('./routes/auth.js')); | |
13 | + | |
14 | + | |
15 | +}; | |
16 | + | |
17 | +exports['@require'] = ['igloo/settings']; | ... | ... |
... | ... | @@ -8,12 +8,18 @@ var bootable = workaiExpress.bootable; |
8 | 8 | |
9 | 9 | IoC.use(IoC.dir(path.join(__dirname, 'boot')));//重载配置 |
10 | 10 | |
11 | -app.boot(function (err) { | |
12 | - if (err) { | |
13 | - console.log(err); | |
14 | - process.exit(-1); | |
15 | - return; | |
16 | - } | |
17 | -}); | |
18 | 11 | |
19 | 12 | |
13 | +IoC.create('igloo/server').then(function (server) { | |
14 | + app.phase(bootable.di.initializers()); | |
15 | + app.phase(bootable.di.routes('./routes')); | |
16 | + app.phase(server); | |
17 | + app.boot(function (err) { | |
18 | + if (err) { | |
19 | + console.log(err); | |
20 | + process.exit(-1); | |
21 | + return; | |
22 | + } | |
23 | + }); | |
24 | +}); | |
25 | + | ... | ... |
请
注册
或
登录
后发表评论