'use strict'; const path = require('path'); const config = require('config'); const express = require('express'); const Router = require('express-promise-router'); const bodyParser = require('body-parser'); const { fetchReleases } = require('./releases'); function initServer() { const app = express(); const router = Router(); router.use('/media', express.static(config.photoPath)); router.use(express.static('public')); router.use(bodyParser.json({ strict: false })); router.get('/api/releases', fetchReleases); router.get('/api/releases/:releaseId', fetchReleases); router.get('*', (req, res) => { res.sendFile(path.join(__dirname, '../../public/index.html')); }); app.use(router); app.listen(config.web.port, () => { console.log(`Web server listening on port ${config.web.port}`); }); } module.exports = initServer;