2024-09-26 01:05:18 +05:00

45 lines
1.1 KiB
TypeScript

import { createClient, createConfig, type Options } from '@hey-api/client-axios';
export const client = createClient(createConfig());
export type StationId = string;
export enum StationStatus {
Online = "Online",
Offline = "Offline",
Receive = "Receive"
};
export enum Playback {
Stopped = "Stopped",
Playing = "Playing",
Paused = "Paused"
};
export type StationInfo = {
id: StationId;
name: string;
status: StationStatus;
url: string | null;
location: string | null;
genre: string | null;
playback: Playback | null;
};
export type SongInfo = {
artist: string | null;
title: string | null;
tags: Array<[string, string]>;
};
export const stationsInfo = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => { return (options?.client ?? client).get<StationInfo[], unknown, ThrowOnError>({
...options,
url: '/api/stations'
}); };
export const songStatus = <ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) => { return (options?.client ?? client).get<SongInfo | null, unknown, ThrowOnError>({
...options,
url: '/api/status'
}); };