littlelink-server/src/index.js

29 lines
627 B
JavaScript
Raw Normal View History

/* eslint-disable no-console */
import express from 'express';
let app = require('./server').default;
if (module.hot) {
module.hot.accept('./server', () => {
console.log('🔁 HMR Reloading `./server`...');
try {
app = require('./server').default;
} catch (error) {
console.error(error);
}
});
console.info('✅ Server-side HMR Enabled!');
}
const port = process.env.PORT || 3000;
export default express()
.use((req, res) => app.handle(req, res))
.listen(port, err => {
if (err) {
console.error(err);
return;
}
console.log(`> Started on port ${port}`);
});