-
Notifications
You must be signed in to change notification settings - Fork 76
/
server.js
43 lines (34 loc) · 1010 Bytes
/
server.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
var config = require("./config.json"),
express = require("express"),
routes = require("./routes.js"),
dbs = require("./libs/connectDbs.js"),
app = express();
config.server.port = process.env.PORT || config.server.port;
config.server.public_dir = process.env.PUBLIC_DIR || config.server.public_dir;
app.configure(function(){
app.use(express.favicon());
app.use(express.logger("dev"));
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express["static"](config.server.public_dir));
});
app.configure("development", function() {
app.use(express.errorHandler({
dumpException: true,
showStack: true
}));
});
dbs.connect(config.dbs, function(errs, clients){
var db;
if(errs){
for(db in errs){
console.log("Error: db[" + db + "] " + errs[db]);
}
}else{
routes.load(app, clients);
app.listen(config.server.port);
console.log("App listening on port: " + config.server.port);
}
});