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-24 14:23:22 +01:00
|
|
|
const route35c3 = require('./route/35c3');
|
|
|
|
|
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-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-24 13:45:01 +01:00
|
|
|
|
|
|
|
module.exports = app;
|
|
|
|
if (!module.parent) {
|
|
|
|
app.listen(8080);
|
|
|
|
}
|