Services/shows: refactor

This commit is contained in:
Toast 2025-02-06 10:54:48 +01:00
parent 8f416cc8b4
commit 0d9b378b8e

View file

@ -14,10 +14,12 @@ export class ShowsApiService {
private readonly url: string = "https://shows.everest.tailscale/api/"; private readonly url: string = "https://shows.everest.tailscale/api/";
private showsEndpoint: string private showsEndpoint: string
private idEndpoint: string
private http: HttpClient = inject(HttpClient); private http: HttpClient = inject(HttpClient);
constructor() { constructor() {
this.showsEndpoint = this.url + "shows/" this.showsEndpoint = this.url + "shows/"
this.idEndpoint = this.showsEndpoint + "id/"
} }
getShows(): Observable<ShowsApiResponse> { getShows(): Observable<ShowsApiResponse> {
@ -25,7 +27,7 @@ export class ShowsApiService {
} }
getShow(id: string): Observable<ShowsApiIdResponse> { getShow(id: string): Observable<ShowsApiIdResponse> {
return this.http.get<ShowsApiIdResponse>(this.showsEndpoint + "id/" + id) return this.http.get<ShowsApiIdResponse>(this.idEndpoint + id)
} }
sendShow(newShow: Show): Observable<ShowsApiCreation> { sendShow(newShow: Show): Observable<ShowsApiCreation> {
@ -33,10 +35,10 @@ export class ShowsApiService {
} }
deleteShw(id: string): Observable<ShowsApiDeletionEdit> { deleteShw(id: string): Observable<ShowsApiDeletionEdit> {
return this.http.delete<ShowsApiDeletionEdit>(this.showsEndpoint + "id/" + id) return this.http.delete<ShowsApiDeletionEdit>(this.idEndpoint + id)
} }
updateShow(show: Show): Observable<ShowsApiDeletionEdit> { updateShow(show: Show): Observable<ShowsApiDeletionEdit> {
return this.http.put<ShowsApiDeletionEdit>(this.showsEndpoint + "id/" + show._id, show) return this.http.put<ShowsApiDeletionEdit>(this.idEndpoint + show._id, show)
} }
} }