2023-02-27 01:54:28 +01:00
|
|
|
import { createContext } from 'react';
|
2022-05-12 08:31:31 +02:00
|
|
|
import { ServerStatus } from '../interfaces/server-status.model';
|
2022-04-26 08:10:07 +02:00
|
|
|
|
2022-05-09 08:28:54 +02:00
|
|
|
const ENDPOINT = `/api/status`;
|
2022-04-26 08:10:07 +02:00
|
|
|
|
2023-02-27 01:54:28 +01:00
|
|
|
export interface ServerStatusStaticService {
|
|
|
|
getStatus(): Promise<ServerStatus>;
|
|
|
|
}
|
|
|
|
|
2022-04-26 08:10:07 +02:00
|
|
|
class ServerStatusService {
|
|
|
|
public static async getStatus(): Promise<ServerStatus> {
|
|
|
|
const response = await fetch(ENDPOINT);
|
|
|
|
const status = await response.json();
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-27 01:54:28 +01:00
|
|
|
export const ServerStatusServiceContext =
|
|
|
|
createContext<ServerStatusStaticService>(ServerStatusService);
|