feat: demo manga search

This commit is contained in:
2024-07-05 01:04:49 +03:00
parent c7d76419f7
commit 37149c83c4
8 changed files with 174 additions and 10 deletions

View File

@@ -0,0 +1,27 @@
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable, catchError, map, throwError } from "rxjs";
import { ESiteUrls } from "../urls";
import { IRulibSearchResult } from "./rulib.dto";
//TODO: Make abstract classes
@Injectable({
providedIn: "root",
})
export class LibSocialParserService {
private readonly url = ESiteUrls.LIB_SOCIAL;
constructor(private readonly http: HttpClient) {}
searchManga(query: string): Observable<IRulibSearchResult> {
return this.http
.get(`${this.url}/api/manga?fields[]=rate_avg&fields[]=rate&q=${query}&site_id[]=1`)
.pipe(
map((data: object) => {
return data as IRulibSearchResult;
}),
catchError((error) => {
return throwError(() => `Now found ${error}`);
}),
);
}
}