-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpea-server.js
More file actions
36 lines (28 loc) · 839 Bytes
/
pea-server.js
File metadata and controls
36 lines (28 loc) · 839 Bytes
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
"use strict";
// Optional. You will see this name in eg. 'ps' or 'top' command
process.title = 'pea-server';
const http = require('http');
const express = require('express');
const randezvous = require('./src/randezvous');
/**
* global variables
*/
const args = process.argv.slice(2);
const httpPort = args.length > 0 && !isNaN(args[0]) ? args[0] : 80;
const serveFolder = "public";
const app = express();
const server = http.createServer(app);
app.use(express.static(__dirname + '/' + serveFolder));
app.get('/:sessionId', (req, res) => {
const sessionId = req.params.sessionId;
if (sessionId) {
res.redirect('client.html?sessionId=' + sessionId);
}
});
randezvous.startWebSocket(server);
/*
* start our server
*/
server.listen(httpPort, () => {
console.log(`Server started on port ${server.address().port} :)`);
});