forked from baytelman/FBMonkeys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (43 loc) · 1.28 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
global.rootRequire = function (name) {
return require(__dirname + '/' + name);
}
var env = process.env.NODE_ENV || 'development'
, express = require('express')
, sassMiddleware = require('node-sass-middleware')
, app = express();
app.set('port', (process.env.PORT || 5000) );
app.set('view engine', 'ejs');
require('express-helpers')(app);
app.use(
sassMiddleware({
src: __dirname + '/sass',
dest: __dirname + '/public/css',
prefix: '/css',
debug: true,
})
);
// Configuration specific to production env
if (env == 'production') {
// Force SSL on heroku by checking the 'x-forwarded-proto' header
const forceSSL = require('express-force-ssl');
app.set('forceSSLOptions', {trustXFPHeader: true});
app.use(forceSSL);
}
app.use(express.static(__dirname + '/public'));
var renderIndex = function (req, res) {
res.render('index', {
userParam: req.param('user')
});
}
// Root route
app.route('/')
.all()
.get(renderIndex)
.post(renderIndex);
// Set up the express application server
var server = app.listen( (process.env.PORT || 5000), function () {
var server_url = server.address()
, host = server_url.address
, port = server_url.port || 5000;
console.log('React City App listening at http://%s:%s', host, port);
});