diff --git a/frontend/src/app/core/services/entry-ratings.service.ts b/frontend/src/app/core/services/entry-ratings.service.ts index c413250..438c406 100644 --- a/frontend/src/app/core/services/entry-ratings.service.ts +++ b/frontend/src/app/core/services/entry-ratings.service.ts @@ -1,13 +1,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { EntrySeen } from '../../shared/models/entrySeen.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntryRatingsService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entry-ratings'; constructor(private http: HttpClient) {} @@ -16,7 +16,7 @@ export class EntryRatingsService { return this.http.put( `${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`, { - entryR: entryRatings + entryR: entryRatings, } ); } diff --git a/frontend/src/app/core/services/entry-seen.service.ts b/frontend/src/app/core/services/entry-seen.service.ts index 92a1852..412e3a3 100644 --- a/frontend/src/app/core/services/entry-seen.service.ts +++ b/frontend/src/app/core/services/entry-seen.service.ts @@ -1,12 +1,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EntrySeen } from '../../shared/models/entrySeen.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntrySeenService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entry-seen'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/entry.service.ts b/frontend/src/app/core/services/entry.service.ts index 59ec2b1..e9cf206 100644 --- a/frontend/src/app/core/services/entry.service.ts +++ b/frontend/src/app/core/services/entry.service.ts @@ -4,13 +4,13 @@ import { Observable, map } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; -// import { environment } from '../../../environments/environment'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EntryService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entries'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/episode-seen.service.ts b/frontend/src/app/core/services/episode-seen.service.ts index 7a8a726..e0d72ff 100644 --- a/frontend/src/app/core/services/episode-seen.service.ts +++ b/frontend/src/app/core/services/episode-seen.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { EpisodeSeen } from '../../shared/models/episodeSeen.model'; import { EpisodeSeenDto } from '../../shared/models/dtos/episode-seen.dto'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EpisodeSeenService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'episode-seen'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/episode.service.ts b/frontend/src/app/core/services/episode.service.ts index 08d2b84..0403219 100644 --- a/frontend/src/app/core/services/episode.service.ts +++ b/frontend/src/app/core/services/episode.service.ts @@ -1,11 +1,12 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class EpisodeService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'episodes'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/importer.service.ts b/frontend/src/app/core/services/importer.service.ts index 67c5a96..cdde7ff 100644 --- a/frontend/src/app/core/services/importer.service.ts +++ b/frontend/src/app/core/services/importer.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { MovieDateSeen } from '../../shared/models/dtos/movieDateSeen.model'; import { HttpClient } from '@angular/common/http'; import { Entry } from '../../shared/models/entry.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class ImporterService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'entries'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/library.service.ts b/frontend/src/app/core/services/library.service.ts index d5cecfd..b34033e 100644 --- a/frontend/src/app/core/services/library.service.ts +++ b/frontend/src/app/core/services/library.service.ts @@ -5,6 +5,7 @@ import { catchError, switchMap, tap } from 'rxjs/operators'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', @@ -13,7 +14,8 @@ export class LibraryService implements OnInit { private libraryEntriesSubject = new ReplaySubject(1); private entriesLoaded = false; - private backend_apiUrl = ' http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; + private apiAction = 'entries'; constructor(private http: HttpClient) {} @@ -48,7 +50,7 @@ export class LibraryService implements OnInit { } private fetchAllEntries(forceFetch: boolean = false): Observable { - const endPoint = `${this.backend_apiUrl}/entries`; + const endPoint = `${this.backend_apiUrl}/${this.apiAction}`; // If data is already loaded and not force fetching, immediately return the cached observable. if (this.entriesLoaded && !forceFetch) { @@ -80,10 +82,13 @@ export class LibraryService implements OnInit { if (existingEntry) { return of(existingEntry); } else { - return this.http.post(`${this.backend_apiUrl}/entries`, { - tmdb_id: tmdb_id, - is_tvserie: is_tvserie, - }); + return this.http.post( + `${this.backend_apiUrl}/${this.apiAction}`, + { + tmdb_id: tmdb_id, + is_tvserie: is_tvserie, + } + ); } }) ); @@ -91,7 +96,7 @@ export class LibraryService implements OnInit { deleteEntry(id: number): Observable { // Directly attempt to delete the entry without fetching all entries first. - return this.http.delete(`${this.backend_apiUrl}/entries/${id}`); + return this.http.delete(`${this.backend_apiUrl}/${this.apiAction}/${id}`); } isInLibrary(tmdb_id: string): Observable { diff --git a/frontend/src/app/core/services/season.service.ts b/frontend/src/app/core/services/season.service.ts index a6ed3e0..b5f9d0e 100644 --- a/frontend/src/app/core/services/season.service.ts +++ b/frontend/src/app/core/services/season.service.ts @@ -2,12 +2,13 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Season } from '../../shared/models/season.model'; import { Episode } from '../../shared/models/episode.models'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class SeasonService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'seasons'; constructor(private http: HttpClient) {} diff --git a/frontend/src/app/core/services/tmdb.service.ts b/frontend/src/app/core/services/tmdb.service.ts index 30cbf6c..2e1f7d0 100644 --- a/frontend/src/app/core/services/tmdb.service.ts +++ b/frontend/src/app/core/services/tmdb.service.ts @@ -4,6 +4,7 @@ import { Observable, from, map, of, switchMap, toArray } from 'rxjs'; import { Entry } from '../../shared/models/entry.model'; import { EntryId } from '../../shared/models/entryId.model'; import { EntryRating } from '../../shared/models/entryRating.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', @@ -14,8 +15,8 @@ export class TmdbService { constructor(private http: HttpClient) {} // private apiUrl = environment.apiBaseUrl; - private tmdb_apiUrl = 'https://api.themoviedb.org/3'; - private tmdb_apiKey = '5323ef3dc430df54dcb9e58c37fd22bb'; + private tmdb_apiUrl = environment.TMDB_API_URL; + private tmdb_apiKey = environment.TMDB_API_KEY; fetchdata(endPoint: string): Observable { if (this.cach[endPoint]) { @@ -34,9 +35,6 @@ export class TmdbService { getEntriesUsingEndPoint(endPoint: string): Observable { return this.fetchdata(endPoint).pipe( - // map((response) => - // response.results.map((movie: any) => this.adaptMovieToEntry(movie)) - // ) map((response) => { // Check if the data is from cache and has `exist` property if (response.exist) { diff --git a/frontend/src/app/core/services/userCollection.service.ts b/frontend/src/app/core/services/userCollection.service.ts index ca913c3..5647c77 100644 --- a/frontend/src/app/core/services/userCollection.service.ts +++ b/frontend/src/app/core/services/userCollection.service.ts @@ -4,12 +4,13 @@ import { Observable } from 'rxjs'; import { UserCollection } from '../../shared/models/userCollection.model'; import { UserCollectionEntry } from '../../shared/models/userCollectionEntry.model'; import { Entry } from '../../shared/models/entry.model'; +import { environment } from '../../../environments/environment.prod'; @Injectable({ providedIn: 'root', }) export class UserCollectionService { - private backend_apiUrl = 'http://localhost:4000/api/v1'; + private backend_apiUrl = environment.API_URL; private apiAction = 'user-collections'; constructor(private http: HttpClient) {} diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts new file mode 100644 index 0000000..57ee8c7 --- /dev/null +++ b/frontend/src/environments/environment.prod.ts @@ -0,0 +1,6 @@ +export const environment = { + production: true, + API_URL: 'http://localhost:4000/api/v1', + TMDB_API_URL: 'https://api.themoviedb.org/3', + TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb', +}; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts new file mode 100644 index 0000000..11a37d4 --- /dev/null +++ b/frontend/src/environments/environment.ts @@ -0,0 +1,6 @@ +export const environment = { + production: false, + API_URL: 'http://localhost:4000/api/v1', + TMDB_API_URL: 'https://api.themoviedb.org/3', + TMDB_API_KEY: '5323ef3dc430df54dcb9e58c37fd22bb', +};