genezio
Version:
Command line utility to interact with Genezio infrastructure.
34 lines (33 loc) • 1.28 kB
JavaScript
import axios from "./axios.js";
import { getAuthToken } from "../utils/accounts.js";
import { BACKEND_ENDPOINT } from "../constants.js";
import version from "../utils/version.js";
import { GENEZIO_NOT_AUTH_ERROR_MSG, UserError } from "../errors.js";
export async function getPresignedURL(region = "us-east-1", archiveName = "genezioDeploy.zip", projectName, deployUnitName) {
if (!region || !archiveName || !projectName || !deployUnitName) {
throw new UserError("Missing required parameters");
}
// Check if user is authenticated
const authToken = await getAuthToken();
if (!authToken) {
throw new UserError(GENEZIO_NOT_AUTH_ERROR_MSG);
}
const json = JSON.stringify({
projectName: projectName,
className: deployUnitName, // we keep className for backward compatibility
filename: archiveName,
region: region,
});
const response = await axios({
method: "GET",
url: `${BACKEND_ENDPOINT}/core/deployment-url`,
data: json,
headers: {
Authorization: `Bearer ${authToken}`,
"Accept-Version": `genezio-cli/${version}`,
},
maxContentLength: Infinity,
maxBodyLength: Infinity,
});
return response.data.presignedURL;
}