Add downloadStorkToml helper and script

This commit is contained in:
Sam Carlton 2022-05-09 16:13:47 -05:00
parent e37364087a
commit 5bbbc7f41c
2 changed files with 37 additions and 0 deletions

28
helpers/api/static.js Normal file
View file

@ -0,0 +1,28 @@
import axios from 'axios'
import 'dotenv/config'
import {
storkVersion,
storkExecutableName,
storkExecutablePath,
storkTomlPath,
} from '~/helpers/stork/config.js'
export async function downloadStorkToml () {
const apiUrl = new URL( process.env.PUBLIC_API_DOMAIN )
apiUrl.pathname = storkTomlPath.replace('/static', '')
console.log('apiUrl', apiUrl)
// await axios( apiUrl.toString() )
axios({
method: "get",
url: apiUrl.toString(),
responseType: "stream"
}).then(function (response) {
response.data.pipe(fs.createWriteStream( storkTomlPath ))
})
}