-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (49 loc) · 1.43 KB
/
index.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
/*jslint node: true, indent: 2, nomen: true, stupid:true */
'use strict';
var express = require('express'),
sections = require('./sections'),
http = require('http'),
path = require('path'),
// Middleware
bodyParser = require('body-parser'),
compression = require('compression'),
expressLess = require('express-less'),
methodOverride = require('method-override'),
morgan = require('morgan'),
// Create server
app = express();
/**
* Configuration
*/
// all environments
app.set('port', process.env.PORT || 4000);
app.set('views', __dirname + '/sections');
app.set('view engine', 'jade');
app.use(morgan('dev'));
app.use(compression());
app.use(methodOverride());
app.use(bodyParser.json());
app.use('/css', expressLess(__dirname + '/sections/_default/less'));
app.use(express.static(path.join(__dirname, 'static')));
app.use('/vendor', express.static(__dirname + '/bower_components'));
/**
* Routes
*/
// Add the routes from the sections
sections(app);
// serve index and view partials
/*jslint unparam:true*/
app.get('/', function (req, res) {
res.render('_default/index');
});
/*jslint unparam:false*/
app.get(/\/html\/([\w\/]+)\.html/, function (req, res) {
var name = req.params[0];
res.render(name);
});
/*
* Start Server
*/
http.createServer(app).listen(app.get('port'), function () {
console.log('Express app listening on port ' + app.get('port'));
});