From 4ed1c7c812361d17bf19640e448c03e510bf8701 Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Wed, 10 May 2023 15:28:00 +0200 Subject: [PATCH] add duplicated routes check --- http_server.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/http_server.ts b/http_server.ts index 328e7b7..3155c39 100644 --- a/http_server.ts +++ b/http_server.ts @@ -130,6 +130,10 @@ export class HTTPServer { add(method: HTTPMethod, path: string, handler: RouteHandler) { const route = new Route(path, method, handler); + if (this.routes.has(route.routeName)) { + console.log(`${route.routeName} already registered!`); + return; + } this.routes.set(route.routeName, route); console.log(`${route.routeName} added`); }