-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
63 lines (49 loc) · 1.71 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//----------------------------------------------
// Set Up Express and Server
//----------------------------------------------
let express = require('express');
let app = express();
let server = require('http').Server(app);
let io = require('socket.io')(server);
require('./game-server/preab.js')(io);
server.listen(process.env.PORT || 2000);
app.get('/',function(req, res) {
res.sendFile(__dirname + '/client/index.html')
});
app.get('/preab', function(req, res) {
res.sendFile(__dirname + '/client/preab/index.html')
});
app.get('/cartai',function(req, res) {
res.sendFile(__dirname + '/client/CartaiVsDaonnachta/index.html')
});
app.get('/boggle', function(req, res) {
res.sendFile(__dirname + '/client/boggle/index.html')
});
app.get('/risk', function(req, res) {
res.sendFile(__dirname + '/client/risk/index.html')
});
app.get('/ris', function(req, res) {
res.sendFile(__dirname + '/client/ris/index.html')
});
app.get('/eolas', function(req, res) {
res.sendFile(__dirname + '/client/about.html')
});
app.get('/sitemap.xml', function(req, res) {
res.sendFile(__dirname + '/sitemap.xml')
});
app.use('/client',express.static('client'));
app.use(express.static('client'));
const lsg = require('./scripts/lsg/lsg.js');
app.get('/api/lsg/:id', function(req, res){
let depth = 1;
if(req.query.depth !== null) depth = req.query.depth;
if (depth > 3) depth = 3;
else if (depth < 1) depth = 1;
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Content-Type', 'application/json');
res.status(200).json(lsg.fetchGraph(req.params.id, depth));
});
app.get('*', function(req, res){ //404 Route (keep as last route)
res.status(404).sendFile(__dirname + '/client/not-found.html');
});
console.log("Server started.");