import express, { Express, NextFunction, Request, Response } from 'express'; import dotenv from 'dotenv' import history from 'connect-history-api-fallback' import routes from './routes' import { logger, errorHandler, uuid } from './util/logger' dotenv.config() const app: Express = express(); const port = process.env.PORT app.use(uuid) app.use(routes) app.use(history()) app.use(express.static('../frontend/dist')) // 404 handler app.use((req, res) => { if (!res.headersSent) { res.status(404).send('404') } }); // handle errors app.use(errorHandler) app.listen(port, () => { console.log('Server up') })