@@ -7,7 +7,10 @@
|
|
7 |
"build": "ng build",
|
8 |
"watch": "ng build --watch --configuration development",
|
9 |
"test": "ng test",
|
10 |
-
"lint": "ng lint"
|
|
|
|
|
|
|
11 |
},
|
12 |
"private": true,
|
13 |
"dependencies": {
|
7 |
"build": "ng build",
|
8 |
"watch": "ng build --watch --configuration development",
|
9 |
"test": "ng test",
|
10 |
+
"lint": "ng lint",
|
11 |
+
"docker:build": "docker build -t book-monkey .",
|
12 |
+
"docker:build:silicon": "npm run docker:build -- --platform=linux/amd64",
|
13 |
+
"docker:redeploy": "docker compose down --remove-orphans && docker compose up -d"
|
14 |
},
|
15 |
"private": true,
|
16 |
"dependencies": {
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"apiUrl": "https://api5.angular-buch.com"
|
3 |
+
}
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"apiUrl": "${API_URL}"
|
3 |
+
}
|
@@ -1,16 +1,18 @@
|
|
1 |
import { HttpClient } from '@angular/common/http';
|
2 |
-
import { Injectable } from '@angular/core';
|
3 |
import { Observable, catchError, of } from 'rxjs';
|
4 |
|
5 |
import { Book } from './book';
|
|
|
6 |
|
7 |
@Injectable({
|
8 |
providedIn: 'root'
|
9 |
})
|
10 |
export class BookStoreService {
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
|
15 |
getAll(): Observable<Book[]> {
|
16 |
return this.http.get<Book[]>(`${this.apiUrl}/books`).pipe(
|
1 |
import { HttpClient } from '@angular/common/http';
|
2 |
+
import { Inject, Injectable } from '@angular/core';
|
3 |
import { Observable, catchError, of } from 'rxjs';
|
4 |
|
5 |
import { Book } from './book';
|
6 |
+
import { API_URL } from './settings';
|
7 |
|
8 |
@Injectable({
|
9 |
providedIn: 'root'
|
10 |
})
|
11 |
export class BookStoreService {
|
12 |
+
constructor(
|
13 |
+
@Inject(API_URL) private apiUrl: string,
|
14 |
+
private http: HttpClient
|
15 |
+
) {}
|
16 |
|
17 |
getAll(): Observable<Book[]> {
|
18 |
return this.http.get<Book[]>(`${this.apiUrl}/books`).pipe(
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { InjectionToken } from '@angular/core';
|
2 |
+
|
3 |
+
export interface Settings {
|
4 |
+
apiUrl: string;
|
5 |
+
}
|
6 |
+
|
7 |
+
export const API_URL = new InjectionToken<string>('apiUrl');
|
@@ -1,7 +1,19 @@
|
|
1 |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
|
2 |
import { AppModule } from './app/app.module';
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
}
|
7 |
-
|
|
|
|
|
|
|
|
|
|
1 |
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
2 |
+
|
3 |
import { AppModule } from './app/app.module';
|
4 |
+
import { API_URL, Settings } from './app/shared/settings';
|
5 |
+
|
6 |
+
async function loadSettings(): Promise<Settings> {
|
7 |
+
const response = await fetch('settings.json');
|
8 |
+
return response.json();
|
9 |
+
}
|
10 |
|
11 |
+
loadSettings().then(settings => {
|
12 |
+
platformBrowserDynamic([
|
13 |
+
{ provide: API_URL, useValue: settings.apiUrl }
|
14 |
+
])
|
15 |
+
.bootstrapModule(AppModule, {
|
16 |
+
ngZoneEventCoalescing: true
|
17 |
+
})
|
18 |
+
.catch(err => console.error(err));
|
19 |
+
});
|