forked from cfsghost/fulfill
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
75 lines (61 loc) · 1.66 KB
/
app.js
File metadata and controls
75 lines (61 loc) · 1.66 KB
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
"use strict";
var path = require('path');
var Frex = require('frex.js');
var Courlan = require('courlan');
var ConfigManager = require('./lib/config_manager');
var Validator = require('./lib/validator');
var app = Frex();
// Loading configuration files
var configManager = new ConfigManager(path.join(__dirname, 'configs'));
configManager.load(function(err, configs) {
app.locals.configs = configs;
// Loading middlewares
Courlan(path.join(__dirname, 'middleware'), function() {
// Configuring
app.configure(function() {
// Configuring engines
app.frex.setEngine('User', {
database: {
driver: configs.app.database.type,
host: configs.app.database.host,
port: configs.app.database.port,
dbName: configs.app.database.dbName,
table: 'user'
},
service: {
service_name: configs.app.service_name,
server_host: configs.app.server_host,
port: configs.app.port
},
mailer: configs.app.mailer
});
// Template engine
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(function(req, res, next) {
res.locals.configs = app.locals.configs;
next();
});
// Session
app.use(Frex.cookieParser());
app.use(Frex.cookieSession({
key: 'fulfill',
secret: configs.app.secret_key
}));
app.use(function(req, res, next) {
res.locals.session = req.session;
next();
});
// Validator
app.use(function(req, res, next) {
req.validator = new Validator();
next();
});
app.use(app.router);
app.use(Frex.static(__dirname + '/public'));
});
app.listen(configs.app.port, function() {
console.log('website is ready.');
});
});
});