New alert service
This commit is contained in:
42
frontend/src/config/services.ts
Normal file
42
frontend/src/config/services.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Service URLs Configuration
|
||||
*
|
||||
* Centralizes all backend service URLs for direct service calls.
|
||||
* Part of Phase 1 architectural refactoring to eliminate orchestrator bottleneck.
|
||||
*/
|
||||
|
||||
const GATEWAY_URL = import.meta.env.VITE_GATEWAY_URL || 'http://localhost:8001';
|
||||
|
||||
export const SERVICE_URLS = {
|
||||
gateway: GATEWAY_URL,
|
||||
orchestrator: `${GATEWAY_URL}/orchestrator`,
|
||||
production: `${GATEWAY_URL}/production`,
|
||||
inventory: `${GATEWAY_URL}/inventory`,
|
||||
alerts: `${GATEWAY_URL}/alerts`,
|
||||
sales: `${GATEWAY_URL}/sales`,
|
||||
procurement: `${GATEWAY_URL}/procurement`,
|
||||
distribution: `${GATEWAY_URL}/distribution`,
|
||||
forecasting: `${GATEWAY_URL}/forecasting`,
|
||||
} as const;
|
||||
|
||||
export type ServiceName = keyof typeof SERVICE_URLS;
|
||||
|
||||
/**
|
||||
* Get full URL for a service endpoint
|
||||
*/
|
||||
export function getServiceUrl(service: ServiceName, path: string): string {
|
||||
const baseUrl = SERVICE_URLS[service];
|
||||
const cleanPath = path.startsWith('/') ? path : `/${path}`;
|
||||
return `${baseUrl}${cleanPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tenant-specific endpoint URL
|
||||
*/
|
||||
export function getTenantEndpoint(
|
||||
service: ServiceName,
|
||||
tenantId: string,
|
||||
endpoint: string
|
||||
): string {
|
||||
return getServiceUrl(service, `/api/v1/tenants/${tenantId}/${endpoint}`);
|
||||
}
|
||||
Reference in New Issue
Block a user