0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2025-01-03 11:20:07 -05:00
safetwitch/server/index.ts
2023-03-07 10:29:05 -05:00

31 lines
623 B
TypeScript

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')
})