From 3cd46d8f4735ab2a1517269b6ba79e0e50c5c9a5 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Fri, 7 May 2021 18:08:14 +0000 Subject: [PATCH] Prevent duplicate service registration in microservice application --- packages/microservice/src/Microservice.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/microservice/src/Microservice.ts b/packages/microservice/src/Microservice.ts index 643c336..1ff7890 100644 --- a/packages/microservice/src/Microservice.ts +++ b/packages/microservice/src/Microservice.ts @@ -160,6 +160,9 @@ export class Microservice */ public installService(this: T, InternalServiceClass: InternalServiceConstructor) { let InternalService = new InternalServiceClass(this); + if (InternalService.NAME in this.services) { + throw new Error("Install Service Error: Attempted to register multiple services with the same name"); + } this.services[InternalService.NAME] = InternalService; }