Improve Angular project structure and code organization (#1328)

This commit is contained in:
Aditya Chandel
2025-10-12 02:01:59 -06:00
committed by GitHub
parent 54a8bacccd
commit 7c9bd56f63
405 changed files with 463 additions and 727 deletions
@@ -0,0 +1,30 @@
import {HttpClient} from '@angular/common/http';
import {Injectable, inject} from '@angular/core';
import {API_CONFIG} from '../../../core/config/api-config';
import {AuthService} from '../../../shared/service/auth.service';
@Injectable({providedIn: 'root'})
export class CbxReaderService {
private readonly pagesUrl = `${API_CONFIG.BASE_URL}/api/v1/cbx`;
private readonly imageUrl = `${API_CONFIG.BASE_URL}/api/v1/media/book`;
private authService = inject(AuthService);
private http = inject(HttpClient);
private getToken(): string | null {
return this.authService.getOidcAccessToken() || this.authService.getInternalAccessToken();
}
private appendToken(url: string): string {
const token = this.getToken();
return token ? `${url}${url.includes('?') ? '&' : '?'}token=${token}` : url;
}
getAvailablePages(bookId: number) {
return this.http.get<number[]>(this.appendToken(`${this.pagesUrl}/${bookId}/pages`));
}
getPageImageUrl(bookId: number, page: number): string {
return this.appendToken(`${this.imageUrl}/${bookId}/cbx/pages/${page}`);
}
}