Skip to content

Commit

Permalink
PI-Key Rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
n0emis committed May 25, 2019
1 parent 720cfe9 commit da2e024
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions api/DB-StaDa.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
const request = require('request');
//var tokens = ['fb06bdc6579f1a78ff221eb4612f45de', '0eb13363c4c00d4dffc0e277c210d6af', '8aa1bbd679c357273cbcdfd9526e78d9', 'ffa19eb6e54c688f45a278c5905ef35b']
var tokens = ['fb06bdc6579f1a78ff221eb4612f45de', '5ed35e0f3f963a87d041bff8688628f5', '3779406152f3222a68d9ceeeb4f24dbb']

exports.getStationInfo = function(id) {
exports.getStationInfo = function(id, i) {
return new Promise((resolve, reject) => {
request({
//url: 'https://api.deutschebahn.com/stada/v2/stations/'+brokenObject.objectId,
url: 'https://api.deutschebahn.com/stada/v2/stations/'+id,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer fb06bdc6579f1a78ff221eb4612f45de',
'Authorization': 'Bearer ' + tokens[i%3],
},
method: 'GET',
json: false,
Expand All @@ -19,7 +21,7 @@ exports.getStationInfo = function(id) {
resolve(JSON.parse(body).result[0].evaNumbers[0].number);
} catch (e) {
console.log(JSON.parse(body));
reject(e);
reject(e + i%3);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ function evaToObject(eva) {

async function translateToEva() {
tempObjs.forEach((tempFac, i) => {
StaDa.getStationInfo(tempObjs[i].objectId).then((number) => {tempObjs[i].evaId = number});
StaDa.getStationInfo(tempObjs[i].objectId, i).then((number) => {tempObjs[i].evaId = number});
})
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dependencies": {
"express": "4.17.0",
"cors": "2.8.5",
"curl": "0.1.4"
"curl": "0.1.4",
"csv-parser": "2.3.0"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit da2e024

Please sign in to comment.