-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
55 lines (47 loc) · 1.7 KB
/
server.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
var express = require('express'),
browserify = require('browserify-middleware'),
hbs = require('express-hbs'),
hbsHelpers = require('./lib/helpers/hbs'),
sass = require('node-sass'),
hdo = require('./lib/hdo'),
logger = require('morgan'),
app = express(),
bowerDir = __dirname + '/client/bower_components',
config = require('./config');
// config
app.use(logger('short'));
app.engine('hbs', hbs.express3({
layoutsDir: __dirname + '/views/_layouts',
defaultLayout: __dirname + '/views/_layouts/default.hbs',
partialsDir: __dirname + '/views/_partials'
}));
hbsHelpers.addTo(hbs);
app.set('port', config.get('PORT'));
app.set('view engine', 'hbs');
app.set('views', __dirname + '/views');
app.disable('x-powered-by');
// middleware
app.use('/javascript', browserify('./client/javascript'));
app.use(sass.middleware({
src: __dirname + '/client',
dest: __dirname + '/public',
debug: true,
outputStyle: 'compressed',
includePaths: [bowerDir + '/twbs-bootstrap-sass/vendor/assets/stylesheets/bootstrap']
}));
if(app.get('env') === 'development') {
app.use(require('errorhandler')());
}
app.use(express.static(__dirname + '/public'));
app.use('/fonts', express.static(bowerDir + '/twbs-bootstrap-sass/vendor/assets/fonts'));
// routes
app.get('/', hdo.handlers.front);
app.get('/representanter/:slug', hdo.handlers.representative);
app.get('/partier/:slug', hdo.handlers.party);
app.get('/saker/:slug', hdo.handlers.issue);
app.get('/saker', hdo.handlers.issues);
app.get('/robots.txt', hdo.handlers.robots);
// launch
app.listen(app.get('port'), function() {
console.log('hdo-front started on ' + app.get('port'));
});