-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
54 lines (54 loc) · 2.26 KB
/
server.js
File metadata and controls
54 lines (54 loc) · 2.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
const fs = require("fs");
const main = require("./functions/main.js");
const express = require('express');
const app = express();
const bodyParser = require("body-parser");
const key = fs.readFileSync('/etc/letsencrypt/live/alexandreapril.com/privkey.pem');
const cert = fs.readFileSync('/etc/letsencrypt/live/alexandreapril.com/fullchain.pem');
const ca = fs.readFileSync('/etc/letsencrypt/live/alexandreapril.com/chain.pem');
const options = { key: key, cert: cert, ca: ca };
const https = require('https');
app.use(bodyParser.raw({ type: "*/*" }));
app.get("/", (req, res) => { res.send(req); });
// Let's a restaurant create an account
app.post("/signup", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.RegisterRestaurant(json)));
});
// Let's a restaurant log into their account, they can then manage their reservations
app.post("/login", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.RestaurantLogIn(json)));
});
// Let's a restaurant change the settings of their restaurant for example the number of Nb2Seaters, Nb3Seaters, etc.
app.post("/settings", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.ChangeSettings(json)));
});
// Reservations cancelled by the restaurant
app.post("/cancelReservation", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.CancelReservation(json)));
});
// Lets the restaurant delete all of their reservations for the day
app.post("/clearAll", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.ClearAll(json)));
});
// Recieves resto number, date and time
app.post("/displayReservations", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.DisplayAllResto(json)));
});
// Reservations confirmed by the restaurant
app.post("/userCreate", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.UserCreateReservation(json)));
});
// Takes the text the user sends to RestoBot and sends RestoBots response
app.post("/message", (req, res) => {
let json = JSON.parse(req.body);
return res.send(JSON.stringify(main.CommunicateWithBot(json)));
});
https.createServer(options, app).listen(443);
app.listen(4000);