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 2222 "port" : 3000 ,
2323 "path" : " /test" ,
2424 "input" : {
25- "method " : " text2"
25+ "request " : " text2"
2626 },
2727 "output" : {
2828 "headers" : {
3939 "port" : 3000 ,
4040 "path" : " /test1" ,
4141 "input" : {
42- "payload " : {
42+ "request " : {
4343 "name" : " John Doe" ,
4444 "age" : 30
4545 }
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ class CreateServer {
3131 }
3232 config . output . response = fs . readFileSync ( config . output . filePath , "utf-8" ) ;
3333 }
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+ }
3440 validateData ( config ) ;
3541 return config ;
3642 } catch ( err ) {
@@ -80,7 +86,7 @@ class CreateServer {
8086 if ( config . method . includes ( req . method ) && config . path === reqUrl ) {
8187 console . log ( chalk . green ( "Matched Config:" ) , config . name ) ;
8288
83- if ( deepCompare ( reqObj , config . input ) ) {
89+ if ( deepCompare ( reqObj , config . input . request ) ) {
8490 console . log ( chalk . green ( "Input Matched" ) ) ;
8591 httpResponse ( res , config ) ;
8692 return ;
You can’t perform that action at this time.
0 commit comments