genezio
Version:
Command line utility to interact with Genezio infrastructure.
40 lines (39 loc) • 1.48 kB
JavaScript
import axios from "./axios.js";
import { getAuthToken } from "../utils/accounts.js";
import { BACKEND_ENDPOINT } from "../constants.js";
import { GENEZIO_NOT_AUTH_ERROR_MSG, UserError } from "../errors.js";
import version from "../utils/version.js";
export var FrontendPresignedURLAppType;
(function (FrontendPresignedURLAppType) {
FrontendPresignedURLAppType["NextJS"] = "nextjs";
FrontendPresignedURLAppType["AutoGenerateDomain"] = "autoGenerateDomain";
})(FrontendPresignedURLAppType || (FrontendPresignedURLAppType = {}));
export async function getFrontendPresignedURL(subdomain, projectName, stage, type) {
const region = "us-east-1";
if (!projectName) {
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({
subdomainName: subdomain,
projectName: projectName,
region: region,
stage: stage,
});
const response = await axios({
method: "GET",
url: `${BACKEND_ENDPOINT}/core/frontend-deployment-url${type ? `?type=${type}` : ""}`,
data: json,
headers: {
Authorization: `Bearer ${authToken}`,
"Accept-Version": `genezio-cli/${version}`,
},
maxContentLength: Infinity,
maxBodyLength: Infinity,
});
return response.data;
}