colouring-montreal/app/src/index.js

33 lines
708 B
JavaScript
Raw Normal View History

2018-09-30 14:50:09 -04:00
/**
* Load server and listen
*
*/
import http from 'http';
import app from './server';
const server = http.createServer(app);
let currentApp = app;
server.listen(process.env.PORT || 3000, error => {
2019-05-27 11:39:16 -04:00
if (error) {
console.log(error);
}
2019-05-27 11:39:16 -04:00
console.log('🚀 started');
});
// In development mode, enable hot module reloading (HMR)
if (module.hot) {
2019-05-27 11:39:16 -04:00
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;
});
}