-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
59 lines (45 loc) · 1.26 KB
/
Copy pathserver.js
File metadata and controls
59 lines (45 loc) · 1.26 KB
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
var express = require("express")
var bodyParser = require("body-parser")
var path = require("path")
var app = express()
var port = process.env.PORT || 3000;
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.text())
app.use(bodyParser.json({ type: "application/vnd.api+json" }))
var waitList = []
var tableList = []
app.get("/", function(req, res) {
res.sendFile(path.join(__dirname, "home.html"));
});
app.get("/tables", function(req, res) {
res.sendFile(path.join(__dirname, "tables.html"));
});
app.get("/reserve", function(req, res) {
res.sendFile(path.join(__dirname, "reserve.html"));
});
app.get("/api/tables", function(req, res) {
res.json(tableList)
});
app.get("/api/waitlist", function(req, res) {
res.json(waitList)
});
app.post("/api/clear", function(req, res) {
waitList = []
tableList =[]
});
app.post("/api/tables", function(req, res) {
var newOrder = req.body;
if (tableList.length < 5) {
tableList.push(newOrder)
console.log(tableList)
res.json(true);
} else {
waitList.push(newOrder)
console.log(waitList)
res.json(false);
}
});
app.listen(port, function() {
console.log("App listening on PORT " + port);
});