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