-
Notifications
You must be signed in to change notification settings - Fork 5
/
bak_app_js.txt
71 lines (65 loc) · 1.6 KB
/
bak_app_js.txt
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
/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var fs = require('fs');
var dbutil = require('./db');
var logger = require('./logger');
var ejs = require('ejs');
var flash = require('connect-flash');
var app = express();
//logs
var accessLogfile = fs.createWriteStream('access.log', {
flags: 'a'
});
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.engine('.html', ejs.__express);
app.set('view engine', 'html');
app.use(express.favicon());
//app.use(express.logger('dev'));
app.use(express.logger({
stream: accessLogfile
}));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(req, res) {
res.status(400);
res.render("404");
});
app.use(function(error, req, res, next) {
res.status(500);
logger.ERROR(error);
res.render("500", {
'error': error
});
});
app.configure(function(){
app.use(flash());
});
/*app.configure('production', function(){
app.error(function (err, req, res, next) {
next();
});
});*/
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
//routes(app);
http.createServer(app).listen(app.get('port'), function() {
console.log('Express server listening on port ' + app.get('port')+" db config "+dbutil.config.port);
});
app.locals({
inspect:function(obj){
return util.inspect(obj,true);
}
});