From 530bf40bae7a25abdb027b4bb68ce4b1c16dabff Mon Sep 17 00:00:00 2001 From: Doron Guttman Date: Wed, 31 Jan 2024 14:01:38 -0500 Subject: [PATCH] =?UTF-8?q?refactor(common):=20=E2=99=BB=EF=B8=8F=20PR=20#?= =?UTF-8?q?13000=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/nestjs/nest/pull/13000 https://github.com/nestjs/nest/issues/12998 --- packages/core/helpers/router-method-factory.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/core/helpers/router-method-factory.ts b/packages/core/helpers/router-method-factory.ts index c761e2df31f..ff31c57e13a 100644 --- a/packages/core/helpers/router-method-factory.ts +++ b/packages/core/helpers/router-method-factory.ts @@ -1,12 +1,7 @@ import { HttpServer } from '@nestjs/common'; import { RequestMethod } from '@nestjs/common/enums/request-method.enum'; -/** - * Ensures (via satisfies) there's a mapping between the RequestMethod enum and the HttpServer interface. - * @note This is a compile-time check, so if the interface changes, the compiler will complain. - * This is to resolve a case where a new RequestMethod is added, but the RouterMethodFactory is not updated. - */ -const RequestMethodMap = { +const REQUEST_METHOD_MAP = { [RequestMethod.GET]: 'get', [RequestMethod.POST]: 'post', [RequestMethod.PUT]: 'put', @@ -20,10 +15,9 @@ const RequestMethodMap = { export class RouterMethodFactory { public get(target: HttpServer, requestMethod: RequestMethod): Function { - const methodName = RequestMethodMap[requestMethod]; + const methodName = REQUEST_METHOD_MAP[requestMethod]; const method = target[methodName]; if (!method) { - // There should probably be a warning message in this case return target.use; } return method;