service outages and use nws api

This commit is contained in:
Nicholas Orlowsky 2022-10-22 16:21:03 -05:00
parent 025e993700
commit 22129d5268
No known key found for this signature in database
GPG key ID: 3845F78A73B14100
5 changed files with 126 additions and 60 deletions

14
src/nws-api/calls.ts Normal file
View file

@ -0,0 +1,14 @@
import {Incident, UptimeResponse} from "./types";
export async function getUptime(): Promise<UptimeResponse> {
let response: Response = await fetch('https://api-nws.nickorlow.com/uptime');
let uptime: UptimeResponse = await response.json();
return uptime;
}
export async function getIncidents(): Promise<Incident[]> {
let response: Response = await fetch('https://api-nws.nickorlow.com/incidents');
let incidents: Incident[] = await response.json();
return incidents;
}

34
src/nws-api/types.ts Normal file
View file

@ -0,0 +1,34 @@
export type UptimeRecord = {
name: string,
url: string,
uptimeMonth: number,
uptimeAllTime: number,
isUp: boolean,
undergoingMaintenance: boolean
};
export type UptimeResponse = {
datacenters: UptimeRecord[],
services: UptimeRecord[]
};
export type Blog = {
id: number,
title: string,
author: string,
content: string,
imageUrl: string
};
export type Incident = {
id: number,
severity: IncidentSeverity,
title: string,
description: string
};
enum IncidentSeverity {
LOW,
MEDIUM,
HIGH
};