services.ts56 lines, 1.2 KB
| 1 | export interface ServiceConfig { |
| 2 | name: string; |
| 3 | url: string; |
| 4 | healthPath: string; |
| 5 | timeout: number; |
| 6 | retries: number; |
| 7 | } |
| 8 | |
| 9 | export interface ServicesConfig { |
| 10 | [key: string]: ServiceConfig; |
| 11 | } |
| 12 | |
| 13 | export const servicesConfig: ServicesConfig = { |
| 14 | auth: { |
| 15 | name: "Auth Service", |
| 16 | url: process.env.AUTH_SERVICE_URL || "http://localhost:3001", |
| 17 | healthPath: "/health", |
| 18 | timeout: 5000, |
| 19 | retries: 3, |
| 20 | }, |
| 21 | users: { |
| 22 | name: "Users Service", |
| 23 | url: process.env.USER_SERVICE_URL || "http://localhost:3002", |
| 24 | healthPath: "/health", |
| 25 | timeout: 5000, |
| 26 | retries: 3, |
| 27 | }, |
| 28 | notes: { |
| 29 | name: "Notes Service", |
| 30 | url: process.env.NOTES_SERVICE_URL || "http://localhost:3003", |
| 31 | healthPath: "/health", |
| 32 | timeout: 5000, |
| 33 | retries: 3, |
| 34 | }, |
| 35 | tags: { |
| 36 | name: "Tags Service", |
| 37 | url: process.env.TAGS_SERVICE_URL || "http://localhost:3004", |
| 38 | healthPath: "/health", |
| 39 | timeout: 5000, |
| 40 | retries: 3, |
| 41 | }, |
| 42 | }; |
| 43 | |
| 44 | export const getServiceConfig = ( |
| 45 | serviceName: string |
| 46 | ): ServiceConfig | undefined => { |
| 47 | return servicesConfig[serviceName]; |
| 48 | }; |
| 49 | |
| 50 | export const getAllServices = (): ServiceConfig[] => { |
| 51 | return Object.values(servicesConfig); |
| 52 | }; |
| 53 | |
| 54 | export const getActiveServices = (): ServiceConfig[] => { |
| 55 | return [servicesConfig.auth, servicesConfig.users]; |
| 56 | }; |