-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (27 loc) · 961 Bytes
/
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
const express = require("express");
const cors = require("cors");
const path = require("path");
const bodyParser = require("body-parser");
const app = express();
const GameRoute = require('./routes/Game').Game;
//handle cors errors
app.use(cors());
app.use(bodyParser.json());
//client page
app.use('/', express.static(path.join(__dirname + '/public/mainclient/build')));
//mobile page
//must be named index.html
app.use("/mobile", express.static(path.join(__dirname + '/public/mobile_controller/build')));
app.use("/public/mobile_controller/build", express.static(path.join(__dirname, "public", "mobile_controller", "build")));
//game page
app.use("/app", express.static(path.join(__dirname + '/public/Game/dist')));
//Game
app.use("/game", GameRoute);
//if no routes are found
app.use((req, res, next) => {
res.writeHeader(404, {
"Content-Type" : "text/plain"
})
res.status(404).end("No Route Found");
})
module.exports = app;