mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-06-22 19:44:15 +02:00
Adjust all endpoints and methods to tranga/postgres-Server-V2.
Search working.
This commit is contained in:
@ -1,33 +1,44 @@
|
||||
import IMangaConnector from './interfaces/IMangaConnector';
|
||||
import IManga from './interfaces/IManga';
|
||||
import { getData } from '../App';
|
||||
import {getData, patchData} from '../App';
|
||||
|
||||
export class MangaConnector
|
||||
{
|
||||
static async GetAllConnectors(): Promise<IMangaConnector[]> {
|
||||
static async GetAllConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all MangaConnectors");
|
||||
return getData("http://127.0.0.1:6531/v2/Connector/Types")
|
||||
return getData(`${apiUri}/v2/MangaConnector`)
|
||||
.then((json) => {
|
||||
//console.info("Got all MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetMangaFromConnectorByTitle(connector: IMangaConnector, name: string): Promise<IManga[]> {
|
||||
//console.info(`Getting Manga ${name}`);
|
||||
return await getData(`http://127.0.0.1:6531/v2/Connector/${connector.name}/GetManga?title=${name}`)
|
||||
static async GetEnabledConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all enabled MangaConnectors");
|
||||
return getData(`${apiUri}/v2/MangaConnector/enabled`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${name}`);
|
||||
return (json as IManga[]);
|
||||
//console.info("Got all enabled MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async GetMangaFromConnectorByUrl(connector: IMangaConnector, url: string): Promise<IManga> {
|
||||
//console.info(`Getting Manga ${url}`);
|
||||
return await getData(`http://127.0.0.1:6531/v2/Connector/${connector.name}/GetManga?url=${url}`)
|
||||
static async GetDisabledConnectors(apiUri: string): Promise<IMangaConnector[]> {
|
||||
//console.info("Getting all disabled MangaConnectors");
|
||||
return getData(`${apiUri}/v2/MangaConnector/disabled`)
|
||||
.then((json) => {
|
||||
//console.info(`Got Manga ${url}`);
|
||||
return (json as IManga);
|
||||
//console.info("Got all disabled MangaConnectors");
|
||||
return (json as IMangaConnector[]);
|
||||
});
|
||||
}
|
||||
|
||||
static async SetConnectorEnabled(apiUri: string, connectorName: string, enabled: boolean): Promise<object> {
|
||||
if(connectorName === undefined || connectorName === null || connectorName.length < 1) {
|
||||
console.error(`connectorName was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
if(enabled === undefined || enabled === null) {
|
||||
console.error(`enabled was not provided`);
|
||||
return Promise.reject();
|
||||
}
|
||||
return patchData(`${apiUri}/v2/MangaConnector/${connectorName}/SetEnabled/${enabled}`, {});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user