-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
28 lines (24 loc) · 950 Bytes
/
server.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
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const webpackMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const config = require('./webpack.config.js');
const router = express.Router();
const isDeveloping = process.env.NODE_ENV !== 'production';
const port = isDeveloping ? 3000 : process.env.PORT;
const app = express();
router.get('/api/data', function(req, res) {
res.sendFile(path.normalize(__dirname + '/app/data/gift.json'))
});
app.use('/', router);
app.use(express.static(__dirname + '/build'));
app.get('/', function response(req, res) {
res.sendFile(path.join(__dirname, 'build/index.html'));
});
app.listen(port, '0.0.0.0', function onStart(err) {
if (err) {
console.log(err);
}
console.info('==> 🌎 Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.', port, port);
});