started using environment variables
This commit is contained in:
1 parent
c9c7a92012
commit
8958ead210
12 files changed
+44
-23
No files matched your search
@@ -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<EntryRating>(
|
||||
`${this.backend_apiUrl}/${this.apiAction}/${entryRatings.id}`,
|
||||
{
|
||||
entryR: entryRatings
|
||||
entryR: entryRatings,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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<Entry[]>(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<Entry[]> {
|
||||
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<Entry>(`${this.backend_apiUrl}/entries`, {
|
||||
tmdb_id: tmdb_id,
|
||||
is_tvserie: is_tvserie,
|
||||
});
|
||||
return this.http.post<Entry>(
|
||||
`${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<any> {
|
||||
// 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<Entry | null> {
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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<any> {
|
||||
if (this.cach[endPoint]) {
|
||||
@@ -34,9 +35,6 @@ export class TmdbService {
|
||||
|
||||
getEntriesUsingEndPoint(endPoint: string): Observable<Entry[]> {
|
||||
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) {
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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',
|
||||
};
|
||||
@@ -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',
|
||||
};
|
||||
Reference in new issue
Block a user