UNPKG

@applicaster/zapplicaster-cli

Version:

CLI Tool for the zapp app and Quick Brick project

51 lines (43 loc) 1.27 kB
const axios = require("axios"); const logger = require("../logger"); /** * module Zapp * @module @applicaster/zapplicaster-cli/utils/zapp */ const { ZAPP_TOKEN } = process.env; const axiosInstance = axios.create({ baseURL: "https://zapp.applicaster.com/api/v1/admin/build_params", params: { access_token: ZAPP_TOKEN, }, headers: { Accept: "application/json", }, }); /** * Takes an app version id and returns the build params from Zapp * @async function - will throw if response code from Zapp is not 2xx/3xx * @param {Strng} app_version_id : id of the app version * @returns {Promise} build params object */ async function getAppVersionParams(app_version_id) { if (!ZAPP_TOKEN) { throw new Error( "no $ZAPP_TOKEN defined - please add it to your environment variables" ); } try { const { data: { build_params }, } = await axiosInstance.get("", { params: { app_version_id: app_version_id.trim() }, }); return build_params; } catch (error) { logger.warn("Failed getting build params from zapp"); logger.warn(`url: ${JSON.stringify(error.config.url)}`); logger.warn(`params: ${JSON.stringify(error.config.params)}`); throw error; } } module.exports = { getAppVersionParams };