-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
app.js
35 lines (28 loc) · 996 Bytes
/
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
/**
* Module dependencies.
*/
var express = require('express')
, http = require('http')
, path = require('path')
, bodyParser = require('body-parser')
, favicon = require('serve-favicon')
, logger = require('morgan')
, methodOverride = require('method-override');
var app = express();
app.set('port', process.env.PORT || 3000);
app.use(favicon(__dirname + '/public/images/favicon.png'));
app.use(logger('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(methodOverride('_method'));
app.use(express.static(path.join(__dirname, 'client/build')));
if (app.get('env') == 'development') {
app.locals.pretty = true;
}
// The "catchall" handler: for any request that doesn't
// match one above, send back React's index.html file.
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname+'/client/build/index.html'));
});
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});