@acontplus/ng-config 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -29
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -224,15 +224,15 @@ export class LocalStorageTokenRepository implements AuthTokenRepository {
|
|
|
224
224
|
|
|
225
225
|
### BaseRepository
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
Interface for common CRUD operations.
|
|
228
228
|
|
|
229
229
|
```typescript
|
|
230
|
-
export
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
export interface BaseRepository<TEntity = any, TId = number> {
|
|
231
|
+
findById(id: TId): Observable<TEntity>;
|
|
232
|
+
findAll(): Observable<TEntity[]>;
|
|
233
|
+
create(entity: Omit<TEntity, 'id'>): Observable<TEntity>;
|
|
234
|
+
update(id: TId, entity: Partial<TEntity>): Observable<TEntity>;
|
|
235
|
+
delete(id: TId): Observable<void>;
|
|
236
236
|
}
|
|
237
237
|
```
|
|
238
238
|
|
|
@@ -242,6 +242,7 @@ export abstract class BaseRepository<T, ID> {
|
|
|
242
242
|
import { BaseRepository } from '@acontplus/ng-config';
|
|
243
243
|
import { Injectable } from '@angular/core';
|
|
244
244
|
import { HttpClient } from '@angular/common/http';
|
|
245
|
+
import { Observable } from 'rxjs';
|
|
245
246
|
|
|
246
247
|
interface User {
|
|
247
248
|
id: number;
|
|
@@ -250,45 +251,49 @@ interface User {
|
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
@Injectable({ providedIn: 'root' })
|
|
253
|
-
export class UserRepository
|
|
254
|
-
constructor(private http: HttpClient) {
|
|
255
|
-
super();
|
|
256
|
-
}
|
|
254
|
+
export class UserRepository implements BaseRepository<User, number> {
|
|
255
|
+
constructor(private http: HttpClient) {}
|
|
257
256
|
|
|
258
|
-
|
|
259
|
-
return this.http.get<User>(`/api/users/${id}`)
|
|
257
|
+
findById(id: number): Observable<User> {
|
|
258
|
+
return this.http.get<User>(`/api/users/${id}`);
|
|
260
259
|
}
|
|
261
260
|
|
|
262
|
-
|
|
263
|
-
return this.http.get<User[]>('/api/users')
|
|
261
|
+
findAll(): Observable<User[]> {
|
|
262
|
+
return this.http.get<User[]>('/api/users');
|
|
264
263
|
}
|
|
265
264
|
|
|
266
|
-
|
|
267
|
-
return this.http.post<User>('/api/users', user)
|
|
265
|
+
create(user: Omit<User, 'id'>): Observable<User> {
|
|
266
|
+
return this.http.post<User>('/api/users', user);
|
|
268
267
|
}
|
|
269
268
|
|
|
270
|
-
|
|
271
|
-
return this.http.put<User>(`/api/users/${id}`, user)
|
|
269
|
+
update(id: number, user: Partial<User>): Observable<User> {
|
|
270
|
+
return this.http.put<User>(`/api/users/${id}`, user);
|
|
272
271
|
}
|
|
273
272
|
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
delete(id: number): Observable<void> {
|
|
274
|
+
return this.http.delete<void>(`/api/users/${id}`);
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
```
|
|
279
278
|
|
|
280
279
|
## Configuration Constants
|
|
281
280
|
|
|
282
|
-
### Authentication
|
|
281
|
+
### Authentication API
|
|
283
282
|
|
|
284
283
|
```typescript
|
|
285
|
-
import {
|
|
284
|
+
import { AUTH_API } from '@acontplus/ng-config';
|
|
285
|
+
|
|
286
|
+
// Authentication API paths
|
|
287
|
+
const authPath = AUTH_API.AUTH; // 'auth/'
|
|
288
|
+
```
|
|
286
289
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
+
### Default Configuration
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
import { DEFAULT_CONFIG } from '@acontplus/ng-config';
|
|
290
294
|
|
|
291
|
-
//
|
|
292
|
-
const apiTimeout =
|
|
293
|
-
const retryAttempts =
|
|
295
|
+
// Full application defaults
|
|
296
|
+
const apiTimeout = DEFAULT_CONFIG.apiTimeout; // 30000
|
|
297
|
+
const retryAttempts = DEFAULT_CONFIG.retryAttempts; // 2
|
|
298
|
+
const enableCorrelationTracking = DEFAULT_CONFIG.enableCorrelationTracking; // true
|
|
294
299
|
```
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acontplus/ng-config",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Angular configuration management library providing environment tokens, application settings, dependency injection patterns, and runtime configuration services for enterprise applications.",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@acontplus/core": "^1.1.
|
|
6
|
+
"@acontplus/core": "^1.1.4",
|
|
7
7
|
"@angular/common": "^21.0.0",
|
|
8
8
|
"@angular/core": "^21.0.0"
|
|
9
9
|
},
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"author": "Ivan Paz <ifer343@gmail.com>",
|
|
44
44
|
"license": "MIT",
|
|
45
45
|
"bugs": {
|
|
46
|
-
"url": "https://github.com/
|
|
46
|
+
"url": "https://github.com/acontplus/acontplus-libs/issues"
|
|
47
47
|
},
|
|
48
|
-
"homepage": "https://github.com/
|
|
48
|
+
"homepage": "https://github.com/acontplus/acontplus-libs#readme",
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/
|
|
51
|
+
"url": "git+https://github.com/acontplus/acontplus-libs.git"
|
|
52
52
|
},
|
|
53
53
|
"release": {
|
|
54
54
|
"branches": [
|