-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
104 lines (101 loc) · 3.66 KB
/
index.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
const express = require('express')
const path = require('path')
const cors = require('cors')
const request = require('request')
const PORT = process.env.PORT || 5000
const app = express()
var corsOptions = {
origin: 'https://ampbyexample.com',
optionsSuccessStatus: 200,
credentials:true
}
app.use(express.static(path.join(__dirname, 'public')))
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
.get('/', (req, res) => res.render('pages/index'))
.listen(PORT, () => console.log(`Listening on ${ PORT }`))
app.options('/dropdown.json', cors(corsOptions))
app.get('/dropdown.json',cors(corsOptions),function (req, res, next) {
var json = {
"items": [{
degrees: [{
"id": 728,
"name": "Bachelor's",
"product": null,
"flexpath": null
}, {
"id": 730,
"name": "Certificate",
"product": null,
"flexpath": null
}, {
"id": 731,
"name": "Doctoral",
"product": null,
"flexpath": null
}, {
"id": 729,
"name": "Master's",
"product": null,
"flexpath": null
}]
}]
};
if(req.query.degree === '728'){
console.log("inside degreee");
json = {
items: [{
aos:[{"id":5896,"name":"Analytics","product":null,"flexpath":null},{"id":733,"name":"Business","product":null,"flexpath":null},{"id":736,"name":"Counseling","product":null,"flexpath":null},{"id":746,"name":"Education ","product":null,"flexpath":null},{"id":3704,"name":"Education Technology","product":null,"flexpath":null},{"id":741,"name":"Health Administration","product":null,"flexpath":null},{"id":748,"name":"Human Resource Management","product":null,"flexpath":null},{"id":764,"name":"Human Services","product":null,"flexpath":null},{"id":2445,"name":"Informatics","product":null,"flexpath":null},{"id":2432,"name":"Information Security","product":null,"flexpath":null},{"id":752,"name":"Information Technology ","product":null,"flexpath":null},{"id":1425,"name":"Nursing ","product":null,"flexpath":null},{"id":761,"name":"Psychology ","product":null,"flexpath":null},{"id":2058,"name":"Public Administration","product":null,"flexpath":null},{"id":5934,"name":"Public Health","product":null,"flexpath":null}]
}]
}
}
if(req.query.degree === '728' & req.query.aos === '5896'){
json = {
items: [{
specialization:[{"id":5898,"name":"Grad Cert - Advanced Analytics Using SAS","product":3671,"flexpath":null},{"id":5897,"name":"Grad Cert - Analytics Using SAS","product":3673,"flexpath":null}]
}]
}
}
res.json(json);
});
app.get('/testing.json',cors(corsOptions),function (req, res, next) {
var url = 'https://s3.amazonaws.com/assets.capella-mt.com/jsondata/group/8';
if(req.query.degree !== undefined){
url+='/'+req.query.degree;
}
if(req.query.aos !== undefined){
url+='/'+req.query.aos;
}
url+='/data.js';
console.log(url);
request.get(url, function(err,httpResponse,body){
var response = {
items:[{
data:[]
}]
};
if(req.query.empty !== 'true'){
try {
response.items[0].data = JSON.parse(body.replace('jsondata(','').replace(')',''));
}catch(e){
console.log(e);
}
}
res.send(response);
});
});
app.get('/submitdata',cors(corsOptions),function (req, res, next) {
res.setHeader('access-control-expose-headers','AMP-Access-Control-Allow-Source-Origin')
res.setHeader('AMP-Access-Control-Allow-Source-Origin', 'https://devwww.capella.edu');
if(req.query.fail === 'true') {
res.status(400).json({
message:"failure message whatever returned from seahawk"
});
} else {
res.status(200).json({
firstName:"susheel",
dynamicLinkLabel:"BS: Bachelor of Science in Information Technology",
dyanamicLink:"/content/capella/en/online-degrees/bachelors-it-data-analytics"
});
}
});