File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 22
22
"port" : 3000 ,
23
23
"path" : " /test" ,
24
24
"input" : {
25
- "method " : " text2"
25
+ "request " : " text2"
26
26
},
27
27
"output" : {
28
28
"headers" : {
39
39
"port" : 3000 ,
40
40
"path" : " /test1" ,
41
41
"input" : {
42
- "payload " : {
42
+ "request " : {
43
43
"name" : " John Doe" ,
44
44
"age" : 30
45
45
}
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ class CreateServer {
31
31
}
32
32
config . output . response = fs . readFileSync ( config . output . filePath , "utf-8" ) ;
33
33
}
34
+ if ( config . input . filePath ) {
35
+ if ( ! fs . existsSync ( config . input . filePath ) ) {
36
+ throw new Error ( `File not found at path: ${ config . input . filePath } ` ) ;
37
+ }
38
+ config . input . request = fs . readFileSync ( config . input . filePath , "utf-8" ) ;
39
+ }
34
40
validateData ( config ) ;
35
41
return config ;
36
42
} catch ( err ) {
@@ -80,7 +86,7 @@ class CreateServer {
80
86
if ( config . method . includes ( req . method ) && config . path === reqUrl ) {
81
87
console . log ( chalk . green ( "Matched Config:" ) , config . name ) ;
82
88
83
- if ( deepCompare ( reqObj , config . input ) ) {
89
+ if ( deepCompare ( reqObj , config . input . request ) ) {
84
90
console . log ( chalk . green ( "Input Matched" ) ) ;
85
91
httpResponse ( res , config ) ;
86
92
return ;
You can’t perform that action at this time.
0 commit comments