colouring-montreal/app/src/index.js

31 lines
613 B
JavaScript
Raw Normal View History

2018-09-30 14:50:09 -04:00
/**
* Load server and listen
*
*/
import app from './server';
import http from 'http';
const server = http.createServer(app);
let currentApp = app;
server.listen(process.env.PORT || 3000, error => {
if (error) {
console.log(error);
}
console.log('🚀 started');
});
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;
});
}