-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (39 loc) · 1.27 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
const configs = require("./configs.js");
const api_paths = require("./api_path.js");
const axios = require('axios');
const express = require('express');
const API_BASE = "https://sandbox.api.visa.com/"
var port = 3000;
const app = express();
const requestOptions = {
httpsAgent: configs.httpsAgent,
headers: {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic ' + new Buffer.from(configs.userId + ':' + configs.password).toString('base64')
}
};
app.get('/helloworld',(req,res)=>{
axios.get(API_BASE + "vdp/helloworld",requestOptions).then(response=>{
res.send(response.data);
})
})
app.get("/companies",(req,res)=>{
let bankId = req.query.bankId;
var url = API_BASE + api_paths.GET_COMPANIES + "?bankId=" + bankId
axios.get(url,requestOptions).then(response=>{
response.data.queryUrl = url;
res.send(response.data);
})
})
app.get("/banks/:bankId",(req,res)=>{
let bankId = req.params["bankId"];
var url = API_BASE + api_paths.GET_BANKS + "/" + bankId
axios.get(url,requestOptions).then(response=>{
response.data.queryUrl = url;
res.send(response.data);
})
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})