-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.js
66 lines (53 loc) · 2.02 KB
/
app.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* Imports */
var express = require('express');
var path = require('path');
var exphbs = require('express-handlebars');
var expressValidator = require('express-validator');
var flash = require('connect-flash');
var session = require('express-session');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var http = require('http');
var d3 = require("d3");
var math = require("mathjs");
var routes = require('./routes/index');
var users = require('./routes/users');
/* Initialize app */
var app = module.exports = express();
/* View Engine */
app.set('views', path.join(__dirname, 'views'));
app.engine('handlebars', exphbs({defaultLayout:'layout'}));
app.set('view engine', 'ejs'); // ejs engine - default engine
app.set('view cache', true);
/* Necessary Middleware */
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', express.static(__dirname + '/www')); // redirect root
app.use('/js', express.static(__dirname + '/node_modules/jquery/dist')); // redirect JS jQuery
app.use('/js', express.static(__dirname + '/node_modules/bootstrap/dist/js')); // redirect bootstrap JS
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css')); // redirect CSS bootstrap
app.use('/css', express.static(__dirname + '/node_modules/font-awesome/css')); // redirect CSS font-awesome
app.use('/scripts', express.static(__dirname + '/node_modules/mathjs/dist/'));
app.use(session({
secret: 'secret',
saveUninitialized: true,
resave: true
}));
app.use(flash());
/* Globals */
app.use(function (req, res, next) {
res.locals.authenticated = false;
next();
});
app.use('/', routes);
app.use('/users', users);
module.exports.app = app;
// Add routing
var existing = require('./routes');