Skip to content

Commit 530bf40

Browse files
committed
refactor(common): ♻️ PR #13000 comments
#13000 #12998
1 parent a7473f2 commit 530bf40

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/core/helpers/router-method-factory.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { HttpServer } from '@nestjs/common';
22
import { RequestMethod } from '@nestjs/common/enums/request-method.enum';
33

4-
/**
5-
* Ensures (via satisfies) there's a mapping between the RequestMethod enum and the HttpServer interface.
6-
* @note This is a compile-time check, so if the interface changes, the compiler will complain.
7-
* This is to resolve a case where a new RequestMethod is added, but the RouterMethodFactory is not updated.
8-
*/
9-
const RequestMethodMap = {
4+
const REQUEST_METHOD_MAP = {
105
[RequestMethod.GET]: 'get',
116
[RequestMethod.POST]: 'post',
127
[RequestMethod.PUT]: 'put',
@@ -20,10 +15,9 @@ const RequestMethodMap = {
2015

2116
export class RouterMethodFactory {
2217
public get(target: HttpServer, requestMethod: RequestMethod): Function {
23-
const methodName = RequestMethodMap[requestMethod];
18+
const methodName = REQUEST_METHOD_MAP[requestMethod];
2419
const method = target[methodName];
2520
if (!method) {
26-
// There should probably be a warning message in this case
2721
return target.use;
2822
}
2923
return method;

0 commit comments

Comments
 (0)