const SERVICE_NAME_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$/; /** * Validates that `serviceName` is a valid service identifier (kebab-case), * safe to use as a URL path segment for routing. Shared between the client * (fail-fast at construction) and the aggregator (registration payload * validation). * @param serviceName the candidate service name * @throws {Error} if `serviceName` does not match the expected kebab-case format */ export function assertValidServiceName(serviceName: string): void { if (!SERVICE_NAME_PATTERN.test(serviceName)) { throw new Error( `Invalid service name "${serviceName}": expected kebab-case (e.g. "my-service").`, ); } }