-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
24 lines (21 loc) · 879 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
const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const webpackConfig = require('./webpack/webpack.config');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 3000;
const compiler = webpack(webpackConfig);
app.use(webpackDevMiddleware(compiler, { noInfo: true, publicPath: webpackConfig.output.publicPath }));
app.use(webpackHotMiddleware(compiler, { log: console.log, path: '/__webpack_hmr', heartbeat: 10 * 1000 }));
app.use(express.static(`${__dirname}/public`));
app.use(bodyParser.json());
app.post('/push', (req, res) => {
console.log(req.body);
console.log(res.body);
res.send('hello');
})
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});