add duplicated routes check

This commit is contained in:
HorizonCode 2023-05-10 15:28:00 +02:00
parent be5c65e759
commit 4ed1c7c812

View File

@ -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`);
}