forked from jsdelivr/bootstrapcdn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
72 lines (60 loc) · 2.14 KB
/
Copy pathapp.js
File metadata and controls
72 lines (60 loc) · 2.14 KB
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
67
68
69
70
71
72
// modules
try {
require('graphdat'); // manually installed, not part of package.json
} catch(e) {
console.log('[NOTE]: graphdat is not installed, given that it\'s an manually installed module and not part of package.json, we\'re ignoring error and continuing.');
}
require('js-yaml');
var express = require('express');
var connect = require('connect');
var http = require('http');
var path = require('path');
var app = express();
var config = require(path.join(__dirname, 'config', '_config.yml'));
// production
app.configure('production', function(){
app.use(connect.logger());
});
// development
app.configure('development', function(){
app.use(connect.logger('dev'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// all environments
app.configure(function() {
app.set('port', process.env.PORT || config.port || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.disable('x-powered-by');
// make config availabile in routes
app.use(function(req,res,next) {
req.config = config;
next();
});
// locals
app.locals({ config: config });
app.locals({ helpers: require('./lib/helpers') });
app.locals({ tweets: require('./config/_tweets.yml') });
// middleware
app.use(express.favicon(path.join(__dirname, config.favicon.ico)));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
// routes
var extras = require('./routes/extras');
app.get('/', require('./routes').index);
app.get('/extras/popular', extras.popular);
app.get('/extras/app', extras.app);
app.get('/extras/birthday', extras.birthday);
// redirects
var redirects = require('./config/_redirects');
Object.keys(redirects).forEach(function(requested) {
app.get(requested, function(req, res) { res.redirect(301, redirects[requested]); });
});
// start
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
// vim: ft=javascript sw=4 sts=4 et: