owncast/web/services/status-service.ts

20 lines
531 B
TypeScript
Raw Normal View History

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