colouring-montreal/app/src/index.ts
Maciej Ziarkowski 4421930942 Squash TypeScript errors and fix bugs
Most errors highglighted by TS were due to a lack of type definitions
and were ignored by settings types to `any`.
Some minor bugs were resolved where the fix was obvious.
TODO marks left where `any` needs to be later removed or bugfix verified
2019-08-09 18:49:43 +01:00

31 lines
703 B
TypeScript

/**
* 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, () => {
console.log('🚀 started');
}).on('error', error => {
console.log(error);
});
// In development mode, enable hot module reloading (HMR)
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;
});
}