Added basic accounts system and integration with new api calls
This commit is contained in:
parent
7df189c3b4
commit
10f347ea0c
5 changed files with 199 additions and 35 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue