infoscreens/server/index.js

43 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2018-12-24 13:45:01 +01:00
const Koa = require('koa');
const Router = require('koa-router');
const Static = require('koa-static');
2018-12-24 14:08:36 +01:00
const Cors = require('koa-cors');
2018-12-26 12:58:20 +01:00
const Mount = require('koa-mount');
2018-12-24 13:45:01 +01:00
const path = require('path');
2018-12-26 18:54:38 +01:00
const routePictures = require('./route/pictures');
2018-12-24 14:23:22 +01:00
const route35c3 = require('./route/35c3');
2019-01-22 22:05:18 +01:00
const routeCalendar = require('./route/calendar');
2019-04-02 22:12:27 +02:00
const routeCBeamRPC = require('./route/cbeamRpc');
2019-05-06 20:33:01 +02:00
const routeMatelight = require('./route/matelight');
2018-12-24 14:23:22 +01:00
2018-12-24 13:45:01 +01:00
const app = new Koa();
const router = new Router();
2018-12-24 14:23:22 +01:00
route35c3(router);
2018-12-26 18:54:38 +01:00
routePictures(router);
2019-01-22 22:05:18 +01:00
routeCalendar(router);
2019-04-02 22:12:27 +02:00
routeCBeamRPC(router);
2019-05-06 20:33:01 +02:00
routeMatelight(router);
2018-12-24 14:23:22 +01:00
2018-12-24 13:45:01 +01:00
app
2018-12-24 14:08:36 +01:00
.use(Cors())
2018-12-24 13:45:01 +01:00
.use(router.routes())
.use(router.allowedMethods())
2018-12-26 12:58:20 +01:00
.use(Static(path.resolve(__dirname, '../dist'), {}))
2018-12-26 13:33:35 +01:00
.use(Mount('/videos', Static(path.resolve(__dirname, '../videos'), {
setHeaders: (res) => {
res.setHeader('cache-control', 'immutable');
},
2018-12-26 18:40:20 +01:00
})))
.use(Mount('/pictures', Static(path.resolve(__dirname, '../pictures'), {
setHeaders: (res) => {
res.setHeader('cache-control', 'immutable');
},
2018-12-26 13:33:35 +01:00
})));
2018-12-24 13:45:01 +01:00
module.exports = app;
if (!module.parent) {
app.listen(8080);
}