36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
'use strict'
|
|
import express from 'express'
|
|
import path from 'path'
|
|
|
|
import config from '../globals'
|
|
import logger from './logger'
|
|
|
|
const app = express()
|
|
const router = express.Router()
|
|
const pubdir = path.join(__dirname, 'public')
|
|
const port = config.server.port || 8080
|
|
const cacheAge = 365 * 24 * 60 * 60 * 1000
|
|
|
|
process.stdin.resume()
|
|
|
|
router.get('/', function (req, res) {
|
|
res.sendFile(path.join(pubdir, '/index.html'))
|
|
})
|
|
|
|
router.get('/:server?*', function (req, res) {
|
|
res.sendFile(path.join(pubdir, '/index.html'))
|
|
})
|
|
|
|
app.use('/', express.static(pubdir, { maxAge: cacheAge }))
|
|
app.use('/', express.static(path.join(pubdir, 'icons'), { maxAge: cacheAge }))
|
|
app.use('/', express.static(path.join(pubdir, 'static'), { maxAge: cacheAge }))
|
|
|
|
app.use('/:server', express.static(pubdir, { maxAge: cacheAge }))
|
|
app.use('/:server', express.static(path.join(pubdir, 'icons'), { maxAge: cacheAge }))
|
|
app.use('/:server', express.static(path.join(pubdir, 'static'), { maxAge: cacheAge }))
|
|
|
|
app.use('/', router)
|
|
app.listen(port, function () {
|
|
logger.log(`*** Listening on http://localhost:${port}/`)
|
|
})
|