-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·59 lines (51 loc) · 1.46 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
/**
* Module dependencies.
*/
var
// ExpressJS modules
express = require('express'),
app = express(),
http = require('http'),
path = require('path'),
// Swig Templates:
// http://paularmstrong.github.com/swig/
cons = require('consolidate'),
swig = require('swig'),
// Setup Dynamic routing, see:
// http://stackoverflow.com/questions/6059246/
routes = require('./routes')(app), // Look in the "routes" directory
// LESS Middelware
// https://github.com/emberfeather/less.js-middleware
lessMiddleware = require('less-middleware');
/**
* Configuration
*/
// Swig templates
swig.init({ root: __dirname + '/views', allowErrors: true });
// Express JS
app.configure(function() {
app.set('port', process.env.PORT || 10576); // port to listen on
app.set('views', __dirname + '/views');
app.engine('.html', cons.swig); // use Swig templates
app.set('view engine', 'html');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
// LESS middleware
// https://npmjs.org/package/less-middleware
app.use(lessMiddleware({
src: __dirname + '/public',
compress: true
}));
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
/**
* Start The server(s)
*/
var server = http.createServer(app);
server.listen(app.get('port'), function() {
console.log("Express server listening on port " + app.get('port'));
});