-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
36 lines (29 loc) · 886 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const Koa = require('koa');
const app = new Koa();
const views = require('koa-views');
const callApp = require('./static');
const staticAssets = require('./serveAssets');
const mount = require('koa-mount');
const cors = require('@koa/cors');
const controllers = require('./controllers');
const mountSocketIo = require('./lib/mountSocketIo');
require('dotenv').config();
app.use(views(__dirname + '/views', {
map: {
html: 'pug'
},
extension: 'pug',
options: {
basedir: require('path').join(__dirname + '/views')
}
}));
app.use(cors());
app.use(mount('/call', callApp));
app.use(mount('/assets', staticAssets));
Object.keys(controllers).forEach(controller => {
app.use(controllers[controller]);
});
const server = require('http').createServer(app.callback());
const io = require('socket.io')(server);
mountSocketIo(io);
server.listen(process.env.PORT || 4000);