Tranga-Website/Website/modules/Manga.tsx

54 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-10-18 02:10:58 +02:00
import IManga from './interfaces/IManga';
import { getData } from '../App';
export class Manga
{
static async GetAllManga(): Promise<IManga[]> {
2024-10-19 21:08:11 +02:00
console.info("Getting all Manga");
2024-10-18 02:10:58 +02:00
return getData("http://127.0.0.1:6531/v2/Mangas")
.then((json) => {
2024-10-19 21:08:11 +02:00
console.info("Got all Manga");
const ret = json as IManga[];
console.debug(ret);
return (ret);
2024-10-18 02:10:58 +02:00
});
}
static async SearchManga(name: string): Promise<IManga[]> {
2024-10-19 21:08:11 +02:00
console.info(`Getting Manga ${name} from all Connectors`);
2024-10-18 02:10:58 +02:00
return await getData(`http://127.0.0.1:6531/v2/Manga/Search?title=${name}`)
.then((json) => {
2024-10-19 21:08:11 +02:00
console.info(`Got Manga ${name}`);
const ret = json as IManga[];
console.debug(ret);
return (ret);
2024-10-18 02:10:58 +02:00
});
}
static async GetMangaById(internalId: string): Promise<IManga> {
2024-10-19 21:08:11 +02:00
console.info(`Getting Manga ${internalId}`);
2024-10-18 02:10:58 +02:00
return await getData(`http://127.0.0.1:6531/v2/Manga/${internalId}`)
.then((json) => {
2024-10-19 21:08:11 +02:00
console.info(`Got Manga ${internalId}`);
const ret = json as IManga;
console.debug(ret);
return (ret);
2024-10-18 02:10:58 +02:00
});
}
static async GetMangaByIds(internalIds: string[]): Promise<IManga[]> {
console.debug(`Getting Mangas ${internalIds.join(",")}`);
return await getData(`http://127.0.0.1:6531/v2/Manga?internalIds=${internalIds.join(",")}`)
.then((json) => {
console.debug(`Got Manga ${internalIds.join(",")}`);
const ret = json as IManga[];
console.debug(ret);
return (ret);
2024-10-18 02:10:58 +02:00
});
}
static GetMangaCoverUrl(internalId: string): string {
2024-10-18 02:10:58 +02:00
console.debug(`Getting Manga Cover-Url ${internalId}`);
return `http://127.0.0.1:6531/v2/Manga/${internalId}/Cover`;
2024-10-18 02:10:58 +02:00
}
}