-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.babel.js
35 lines (29 loc) · 1.05 KB
/
server.babel.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
/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */
import 'babel-core/polyfill';
import path from 'path';
import http from 'http';
import bodyParser from 'body-parser';
import express from 'express';
const server = global.server = express();
// configure app to use bodyParser()
// this will let us get the data from a POST
server.use(bodyParser.urlencoded({ extended: true }));
server.use(bodyParser.json());
server.set('port', (process.env.PORT || 5000));
server.use(express.static('public'));
//
// Register server-side rendering middleware
// -----------------------------------------------------------------------------
server.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
//
// Launch the server
// -----------------------------------------------------------------------------
server.listen(server.get('port'), () => {
/* eslint-disable no-console */
console.log('The server is running at http://localhost:' + server.get('port'));
if (process.send) {
process.send('online');
}
});