-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
82 lines (61 loc) · 2.12 KB
/
app.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var util = require('util');
var path = require('path');
var _ = require('underscore');
_.str = require('underscore.string');
_.mixin(_.str.exports());
var express = require('./node_modules/nuby-express/node_modules/express');
var ejs = require('./node_modules/nuby-express/node_modules/ejs');
var ne_static = require('./node_modules/nuby-express/lib/ne_static');
var ne = require('./node_modules/nuby-express');
var mongoose_init = require('./mongoose');
var session_secret = "I want to believe";
var port = 5103;
var static_contexts = [
{root:__dirname + '/public', prefix:''}
];
var app = express.createServer();
//app.use(express.logger(...));
app.use(express.bodyParser());
app.use(express.cookieParser());
app.set('flash', true);
var MemoryStore = express.session.MemoryStore;
var session_store = new MemoryStore();
var session = express.session({secret:session_secret, store: session_store});
app.use(session);
app.set('session', session);
app.set('session_store', session_store);
app.set('view_engine', 'ejs');
app.register('.html', ejs);
app.set('view options', {layout:true});
app.set('views', __dirname + '/views');
app.set('static contexts', static_contexts);
app.use(ne_static({contexts:static_contexts}));
var fw_configs = {
params:{
session_secret:session_secret,
flash_keys:['info', 'error'],
mongo_params: mongoose_init.params,
layout_id:'h5'
},
resources:{menu: require('./menu')},
app_root:__dirname,
app:app,
ejs: ejs,
_mongoose:null
}
var framework = new ne.Framework(fw_configs);
function _after_load() {
function _on_mongoose_connected() {
console.log('loaded ... listening on %s', port);
app.listen(port);
}
framework.get_param({}, 'mongo_params', function (err, mongo_params) {
mongoose_init.connect(mongo_params, _on_mongoose_connected);
});
}
var layout_path = path.resolve(__dirname, 'layout');
console.log('layouts from %s', layout_path);
framework.add_layouts(layout_path, function () {
var loader = new ne.Loader();
loader.load(framework, _after_load, [ __dirname + '/app', __dirname + '/nuby-members']);
});