silvrgit/single.js

40 lines
1.3 KiB
JavaScript
Raw Normal View History

var express = require('express'), path = require('path'), http = require('http'), morgan = require(
'morgan'), cookieParser = require('cookie-parser'), session = require(
'express-session'), methodoverride = require('method-override'), bodyparser = require(
'body-parser'), errorhandler = require('errorhandler');
var logger = require('log4js').getLogger();
2016-03-08 21:52:21 +00:00
var app = express();
GLOBAL.lastcheck = 0;
//app.configure(function () {
app.set('port', process.env.PORT || 9000);
app.set('view engine', 'ejs');
app.use(morgan('dev'));
app.use(cookieParser('your secret here'));
app.use(session({
secret: '1234567890QWERTY', resave: false, saveUninitialized: false
}));
/* 'default', 'short', 'tiny', 'dev' */
app.use(methodoverride());
2016-03-08 21:52:21 +00:00
app.use(bodyparser.urlencoded({extended: false}));
2016-03-08 21:52:21 +00:00
// parse application/json
app.use(bodyparser.json());
2016-03-08 21:52:21 +00:00
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
2016-03-08 21:52:21 +00:00
});
// app.use(app.router);
app.use(express.static(path.join(__dirname, 'app')));
app.use(errorhandler({dumpExceptions: true, showStack: true}));
2016-03-08 21:52:21 +00:00
http.createServer(app).listen(app.get('port'), function() {
logger.warn("Simple Express server listening on port " + app.get('port'));
//console.log("Express server listening on port " + app.get('port'));
2016-03-08 21:52:21 +00:00
});