31 lines
673 B
TypeScript
31 lines
673 B
TypeScript
export const API_ROOT_URL = new URL("http://techgames.gnetx.com/infoscreen");
|
|
export const CONTENT_ROOT_URL = new URL("/listings", API_ROOT_URL);
|
|
|
|
export enum ListingType {
|
|
IMAGE = "IMAGE",
|
|
VIDEO = "VIDEO",
|
|
}
|
|
|
|
export interface Listing {
|
|
name: string;
|
|
type: ListingType;
|
|
content: string;
|
|
time?: number;
|
|
}
|
|
|
|
export interface Data {
|
|
listings: Listing[];
|
|
}
|
|
|
|
export async function fetchData(): Promise<Data> {
|
|
const response = await fetch(`${API_ROOT_URL}/config.json`, {
|
|
cache: "no-store",
|
|
});
|
|
|
|
return await response.json();
|
|
}
|
|
|
|
export function generateContentURL(content: string): URL {
|
|
return new URL(encodeURIComponent(content), CONTENT_ROOT_URL);
|
|
}
|