@@ -21,16 +21,19 @@ const loadConfig = (endpointsFile) => {
21
21
}
22
22
} ;
23
23
24
+ // "SELECT *\n FROM foo" => "SELECT * FROM foo"
25
+ const flattenQuery = ( query ) => query . replace ( / \n [ ] * / g, ' ' ) ;
26
+
24
27
const createEndpoints = async ( destDir , fileName , config ) => {
25
28
console . log ( 'Generate' , fileName ) ;
26
29
const resultFile = path . join ( destDir , fileName ) ;
27
30
28
31
for ( let endpoint of config ) {
29
32
if ( endpoint . hasOwnProperty ( 'get' ) ) {
30
- console . log ( 'GET' , endpoint . path , '=>' , endpoint . get ) ;
33
+ console . log ( 'GET' , endpoint . path , '=>' , flattenQuery ( endpoint . get ) ) ;
31
34
}
32
35
if ( endpoint . hasOwnProperty ( 'post' ) ) {
33
- console . log ( 'POST' , endpoint . path , '=>' , endpoint . post ) ;
36
+ console . log ( 'POST' , endpoint . path , '=>' , flattenQuery ( endpoint . post ) ) ;
34
37
}
35
38
}
36
39
@@ -56,7 +59,7 @@ const createEndpoints = async (destDir, fileName, config) => {
56
59
57
60
// "SELECT *\n FROM foo" => "'SELECT * FROM foo'"
58
61
"formatQuery" : ( query ) => {
59
- return "'" + query . replace ( / \n [ ] * / g , ' ' ) + "'" ;
62
+ return "'" + flattenQuery ( query ) + "'" ;
60
63
}
61
64
}
62
65
) ;
0 commit comments