erratic-gate/src/server.ts

17 lines
386 B
TypeScript
Raw Normal View History

import express, { static as _static } from 'express'
import { resolve } from 'path'
2019-08-03 23:55:22 +02:00
// create express app
const app = express()
2019-08-03 23:55:22 +02:00
// serve static assets
app.use(_static(__dirname))
2019-08-03 23:55:22 +02:00
// serve single page application
2019-07-28 11:16:49 +02:00
app.get('*', (rex, res) => {
res.sendFile(resolve(__dirname, 'index.html'))
})
2019-08-03 23:55:22 +02:00
// listen to the port from .env (default to 8080)
app.listen(process.env.PORT || 8080)