-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (38 loc) · 1002 Bytes
/
index.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
40
41
42
// Required Modules
import express from 'express'
import cors from 'cors'
import http from 'http'
import router from './api/router.js'
import WebSocketServer from './wss/index.js'
import { actions } from './wss/modules/store.js'
import { eventLog } from './wss/modules/util.js'
// Init App
const app = express()
app.use(cors())
app.use(router)
// Init Server
const server = http.createServer(app)
const port = 80
// Start Lobby
async function startLobby() {
const start_lobby_request = await actions.startLobby()
// Start WebSocket & HTTP Server
if (start_lobby_request.status === 200) {
WebSocketServer(server)
server.listen(port, () => {
eventLog({
request: 'Start Lobby',
status: start_lobby_request.status,
message: start_lobby_request.message
})
})
} else {
// Log Error
eventLog({
request: 'Start Lobby',
status: start_lobby_request.status,
message: start_lobby_request.message
})
}
}
startLobby()