colouring-montreal/app/src/index.ts

31 lines
703 B
TypeScript
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, () => {
2019-05-27 11:39:16 -04:00
console.log('🚀 started');
}).on('error', error => {
console.log(error);
});
// 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;
});
}