-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
107 lines (75 loc) · 3.26 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
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
98
99
100
101
102
103
104
105
106
107
// -------------------- Imports! -------------------
// -------------------- Imports! -------------------
// -------------------- Imports! -------------------
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var request = require('request');
// -------------------- Imports! -------------------
// -------------------- Imports! -------------------
// -------------------- Imports! -------------------
// -------------------- Local Variables! -------------------
// -------------------- Local Variables! -------------------
// -------------------- Local Variables! -------------------
var orders= [];
// -------------------- Local Variables! -------------------
// -------------------- Local Variables! -------------------
// -------------------- Local Variables! -------------------
// -------------------- Server Settings! -------------------
// -------------------- Server Settings! -------------------
// -------------------- Server Settings! -------------------
app.use(express.static('Ecom2018/www')); // directory to pull pages from
app.use(bodyParser.json()); // request parser to use
app.use(bodyParser.urlencoded({ extended: true })); // this came from stackoverflow
// -------------------- Server Settings! -------------------
// -------------------- Server Settings! -------------------
// -------------------- Server Settings! -------------------
// -------------------- Server Routing! -------------------
// -------------------- Server Routing! -------------------
// -------------------- Server Routing! -------------------
// Tend an incomming dispute
app.post('/fileDispute', function(req,res) {
var data = req.body;
// (title, date, name_user, name_product, descript, status , purches_date, email ,cc4 )
var ord = new Order(
'dispute from ' + data.name, //title
data.date, //date
data.name, //name_user
data.product, //name_product
data.freeText, //descript
data.status, //status
data.purches_date, //purches_date
data.email, //email
data.cc4 //cc4
);
orders.push(ord);
res.send('we\'re good');
console.log(orders);
console.log('**************************************************');
console.log('**************************************************');
console.log('**************************************************');
//TODO: mail the mofo
});
// minor change
// Retrive all disputes
app.get('/getDisputes', function (req, res) {
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(orders));
});
var server = app.listen(8081, function () {
var host = server.address().address;
var port = server.address().port;
console.log("Example app listening at http://%s:%s", host, port);
});
function Order(title, date, name_user, name_product, descript, status,purches_date, email,cc4) {
this.title = title;
date = (new Date().toString()).substring(0, 25);
this.date = date;
this.name_user = name_user;
this.name_product = name_product;
this.descript = descript;
this.status = "request";
//Roy added fields
this.email = email;
this.cc4=cc4;
}