2018-09-30 14:50:09 -04:00
|
|
|
/**
|
|
|
|
* Load server and listen
|
|
|
|
*
|
|
|
|
*/
|
2018-09-09 17:22:44 -04:00
|
|
|
import http from 'http';
|
|
|
|
|
2019-04-27 08:25:08 -04:00
|
|
|
import app from './server';
|
|
|
|
|
|
|
|
|
2018-09-09 17:22:44 -04:00
|
|
|
const server = http.createServer(app);
|
|
|
|
|
|
|
|
let currentApp = app;
|
|
|
|
|
|
|
|
server.listen(process.env.PORT || 3000, error => {
|
|
|
|
if (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('🚀 started');
|
|
|
|
});
|
|
|
|
|
2019-04-27 08:25:08 -04:00
|
|
|
// In development mode, enable hot module reloading (HMR)
|
2018-09-09 17:22:44 -04:00
|
|
|
if (module.hot) {
|
|
|
|
console.log('✅ Server-side HMR Enabled!');
|
|
|
|
|
|
|
|
module.hot.accept('./server', () => {
|
|
|
|
console.log('🔁 HMR Reloading x`./server`...');
|
|
|
|
server.removeListener('request', currentApp);
|
|
|
|
const newApp = require('./server').default;
|
|
|
|
server.on('request', newApp);
|
|
|
|
currentApp = newApp;
|
|
|
|
});
|
|
|
|
}
|