@@ -21,16 +21,19 @@ const loadConfig = (endpointsFile) => {
2121 }
2222} ;
2323
24+ // "SELECT *\n FROM foo" => "SELECT * FROM foo"
25+ const flattenQuery = ( query ) => query . replace ( / \n [ ] * / g, ' ' ) ;
26+
2427const createEndpoints = async ( destDir , fileName , config ) => {
2528 console . log ( 'Generate' , fileName ) ;
2629 const resultFile = path . join ( destDir , fileName ) ;
2730
2831 for ( let endpoint of config ) {
2932 if ( endpoint . hasOwnProperty ( 'get' ) ) {
30- console . log ( 'GET' , endpoint . path , '=>' , endpoint . get ) ;
33+ console . log ( 'GET' , endpoint . path , '=>' , flattenQuery ( endpoint . get ) ) ;
3134 }
3235 if ( endpoint . hasOwnProperty ( 'post' ) ) {
33- console . log ( 'POST' , endpoint . path , '=>' , endpoint . post ) ;
36+ console . log ( 'POST' , endpoint . path , '=>' , flattenQuery ( endpoint . post ) ) ;
3437 }
3538 }
3639
@@ -56,7 +59,7 @@ const createEndpoints = async (destDir, fileName, config) => {
5659
5760 // "SELECT *\n FROM foo" => "'SELECT * FROM foo'"
5861 "formatQuery" : ( query ) => {
59- return "'" + query . replace ( / \n [ ] * / g , ' ' ) + "'" ;
62+ return "'" + flattenQuery ( query ) + "'" ;
6063 }
6164 }
6265 ) ;
0 commit comments