-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (47 loc) · 1.34 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
var express = require('express');
var path = require('path');
// Loads the various route files
var routes = require('./routes/index'),
about = require('./routes/about');
var exphbs = require('express3-handlebars'),
Handlebars = require('handlebars');
var weather = require('./lib/weather.js');
var hbs = exphbs.create({
defaultLayout: 'main',
handlebars: Handlebars
});
var app = express();
app.engine('handlebars', hbs.engine);
app.set('view engine', 'handlebars');
// Specifies a path for static files and views for client side
app.use(express.static(path.join(__dirname, 'public')));
app.use('/bower_components', express.static(__dirname + '/bower_components'));
// Add middleware
app.use(function (req,res,next) {
if (!res.locals.partials) res.locals.partials = {};
res.locals.partials.weather = weather.getWeatherData();
next();
});
// Defines the routes to use given the URL path
app.use('/', routes);
app.use('/about', about);
app.use('/timeline', function(req, res) {
res.render('timeline');
});
app.use('/highmaps', function(req, res) {
res.render('highmaps');
});
app.use('/contracts', function(req, res) {
res.render('contracts');
});
// custom 404 page
app.use(function(req, res) {
res.status(404);
res.render('404');
});
// custom 500 page
app.use(function(req, res) {
res.status(500);
res.render('500');
});
module.exports = app;