-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (26 loc) · 927 Bytes
/
app.js
File metadata and controls
29 lines (26 loc) · 927 Bytes
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
const https = require('https');
const url = "https://raw.githubusercontent.com/outages/aws-outages/main/aws_outages.json";
let req = https.get(url, (res) => {
let data = '', json_data;
res.on('data', function (stream) {
data += stream;
});
res.on('end', () => {
var incidents = new Map();
var archive = JSON.parse(data).archive;
for (var i = 0; i < archive.length; i++) {
var date = new Date(archive[i].date * 1000);
var year = date.getFullYear();
var count = incidents.get(year) == undefined ? 0 : incidents.get(year);
count++;
incidents.set(year, count);
}
console.log("AWS Service Outages by The Year\n");
for (const [year, count] of incidents.entries()) {
console.log("%d: %d", year, count);
}
});
});
req.on('error', function (e) {
console.log(e.message);
});