35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { HttpClient, type HttpClientOptions } from './http-client';
|
|
import { createAdminResource, type AdminResource } from './resources/admin';
|
|
import { createAuthResource, type AuthResource } from './resources/auth';
|
|
import { createCatalogResource, type CatalogResource } from './resources/catalog';
|
|
import { createCatalogAdminResource, type CatalogAdminResource } from './resources/catalog-admin';
|
|
import { createHealthResource, type HealthResource } from './resources/health';
|
|
|
|
/**
|
|
* Resource modules are added here as the backend grows — one file per bounded
|
|
* context under `src/resources/`, mirroring the NestJS module names exactly.
|
|
* Keep them thin: URL + types, no business logic and no caching policy (that is
|
|
* the calling app's decision).
|
|
*/
|
|
export interface ApiClient {
|
|
readonly http: HttpClient;
|
|
readonly health: HealthResource;
|
|
readonly catalog: CatalogResource;
|
|
readonly auth: AuthResource;
|
|
readonly admin: AdminResource;
|
|
readonly catalogAdmin: CatalogAdminResource;
|
|
}
|
|
|
|
export function createApiClient(options: HttpClientOptions): ApiClient {
|
|
const http = new HttpClient(options);
|
|
|
|
return {
|
|
http,
|
|
health: createHealthResource(http),
|
|
catalog: createCatalogResource(http),
|
|
auth: createAuthResource(http),
|
|
admin: createAdminResource(http),
|
|
catalogAdmin: createCatalogAdminResource(http),
|
|
};
|
|
}
|