-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
45 lines (38 loc) · 1.33 KB
/
main.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
// postShuffle -- web forum software for node.js
// Copyright (c) 2012 Mooneer Salem
var express = require('express');
var app = express();
var Controller = require(__dirname + '/Controller');
var AppConfig = require('./AppConfig.js');
var consolidate = require('consolidate');
// Initialize Express middleware.
var compression = require('compression')
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser')
var expressSession = require('express-session')
var serveIndex = require('serve-index')
var serveStatic = require('serve-static')
app.use(compression());
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
app.use(cookieParser(AppConfig.sessionSecret, {}));
app.use(expressSession());
app.use('/static', serveIndex(__dirname + '/static'));
app.use('/static', serveStatic(__dirname + '/static'));
// Triggers initialization of database.
var database = require(__dirname + '/DataModel');
// Initialize controller.
var controller = new Controller(app);
controller.link_routes(__dirname);
// Initialize template engine.
app.engine('html', consolidate.mustache);
app.set('view engine', 'html');
app.set('views', __dirname + '/templates');
// Begin listening for connections.
var portNumber = process.env.PORT;
if (!portNumber)
{
// Default to 8080 if not specified.
portNumber = 8080;
}
app.listen(8080);