Added basic accounts system and integration with new api calls

This commit is contained in:
Nicholas Orlowsky 2022-11-10 14:12:43 -06:00
parent 7df189c3b4
commit 10f347ea0c
5 changed files with 199 additions and 35 deletions

View file

@ -1,4 +1,4 @@
import {Blog, Incident, UptimeResponse} from "./types";
import {Blog, Incident, Service, SessionKey, UptimeResponse} from "./types";
export async function getUptime(): Promise<UptimeResponse> {
let response: Response = await fetch('https://api-nws.nickorlow.com/uptime');
@ -18,4 +18,21 @@ export async function getBlogs(): Promise<Blog[]> {
return blogs;
}
export async function getSessionKey(accountId: string, password: string): Promise<SessionKey> {
let response: Response = await fetch('https://api-nws.nickorlow.com/Account/session',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'id': accountId,
'password': password
})
});
let sessionKey: SessionKey = await response.json();
return sessionKey;
}

View file

@ -29,7 +29,39 @@ export type Incident = {
};
enum IncidentSeverity {
LOW,
MEDIUM,
HIGH
LOW,
MEDIUM,
HIGH
};
// Below is primarily for user-facing things
export type Account = {
id?: string,
email: string,
name?: string,
password?: string,
status?: string
};
export type Service = {
serviceId: string,
serviceName: string,
namespace: string,
containerUrl: string,
ownerId: string
}
export type ApiError = {
StatusCode: number,
ErrorMessage: string
};
export type SessionKey = {
id: string,
expiry: Date,
accountId: string,
ip: string
};