-
Notifications
You must be signed in to change notification settings - Fork 17
/
index-doug.js
97 lines (58 loc) · 1.68 KB
/
index-doug.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const express = require('express')
const app = express()
////
//const db = require("mongodb")
//const dbLink = "mongodb://localhost:27017/test"
//const MongoClient = db.MongoClient
////
app.use('/public',express.static('public'))
app.use(express.json('*/*'))
app.get('/', (req, res) => res.send('<html><body><h2>This is smaller</h2></body></html>'))
app.get('/test', (req, res) => res.send('<html><body><h1>This is bigger</h1></body></html>'))
let jsonObj = { "name": "supreme",
"size": 12,
"crust": "deep",
"imgURL": "http://www.sugardale.com/sites/default/files/stuffed%20crust%20pizza.jpg"
}
app.get('/deals', (req, res) => res.send(JSON.stringify(jsonObj)))
app.listen(3000,
() => console.log("Listening on port 3000"))
/////----- customer
app.post('/account/newuser', (req, res) => {
//parse req for account data
let accountData = req.body
// ...
registerNewUser(accountData)
// Respond telling them that it worked...
let respObj = { "resultCode": 200, "result": "OK"}
res.send(JSON.stringify(respObj))
})
function registerNewUser(accountData) {
console.log("Got user data", accountData)
// submit data to mongo....
}
/*
getUserInfo(user)
modifyUserAccount(user,changes)
deleteUserAccount(user)
*/
/////----- discover
/*
getMenu()
getWebsiteData()
*/
/////----- order
/*
recordProductInRecentlyPurchased(product)
addToCart(product,amount)
removeFromCart(product,amount)
clearCart()
checkout()
sendOrderToStore(cart,customerinfo)
*/
/////----- admin
/*
addProductToMenu(product)
removeProductFromMenu(product)
modifyProductOnMenu(product)
*/