-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
39 lines (31 loc) · 1.14 KB
/
app.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
37
38
39
const http = require('http');
const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
const expressHbs = require('express-handlebars');
const session = require('express-session');
const colyseus = require('colyseus');
const landingPageRoute = require('./routes/landing-page');
const homeRoute = require('./routes/home');
const gameRoute = require('./routes/game');
const typeroom = require('./room/typeroom');
const app = express();
const gameServer = new colyseus.Server({
server: http.createServer(app)
});
//register another room with the same class but with a private option
gameServer.register('typeroom', typeroom, {
private: false,
});
gameServer.register('typeroom-private', typeroom, {
private: true
});
app.engine('hbs', expressHbs());
app.set('view engine', 'hbs');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(session({ saveUninitialized: false, resave: false, secret: 'ape' }));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/home', homeRoute);
app.use('/game', gameRoute);
app.use(landingPageRoute);
gameServer.listen(process.env.PORT || 3000);