File tree 1 file changed +2
-8
lines changed
1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { HttpServer } from '@nestjs/common' ;
2
2
import { RequestMethod } from '@nestjs/common/enums/request-method.enum' ;
3
3
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 = {
10
5
[ RequestMethod . GET ] : 'get' ,
11
6
[ RequestMethod . POST ] : 'post' ,
12
7
[ RequestMethod . PUT ] : 'put' ,
@@ -20,10 +15,9 @@ const RequestMethodMap = {
20
15
21
16
export class RouterMethodFactory {
22
17
public get ( target : HttpServer , requestMethod : RequestMethod ) : Function {
23
- const methodName = RequestMethodMap [ requestMethod ] ;
18
+ const methodName = REQUEST_METHOD_MAP [ requestMethod ] ;
24
19
const method = target [ methodName ] ;
25
20
if ( ! method ) {
26
- // There should probably be a warning message in this case
27
21
return target . use ;
28
22
}
29
23
return method ;
You can’t perform that action at this time.
0 commit comments