UNPKG

zephyr-agent

Version:
39 lines (38 loc) • 1.39 kB
import "node:module"; import { getApplicationConfiguration } from "../edge-requests/get-application-configuration.mjs"; import { ZeErrors, ZephyrError } from "../errors/index.mjs"; import { makeRequest } from "../http/http-request.mjs"; import { ze_log } from "../logging/index.mjs"; async function zeEnableSnapshotOnPages({ pluginOptions: { application_uid }, envs_jwt, pages_url }) { ze_log.snapshot('Enabling snapshot on cloudflare pages'); ze_log.snapshot(`Uploading envs to Zephyr, for ${application_uid}`); const type = 'pages'; const json = JSON.stringify({ ...envs_jwt, pages_url }); const { EDGE_URL, jwt } = await getApplicationConfiguration({ application_uid }); const [ok, cause] = await makeRequest({ path: '/upload', base: EDGE_URL, query: { type } }, { method: 'POST', headers: { 'Content-Length': Buffer.byteLength(json).toString(), 'Content-Type': 'application/json; charset=utf-8', can_write_jwt: jwt } }, json); if (!ok) throw new ZephyrError(ZeErrors.ERR_DEPLOY_LOCAL_BUILD, { cause, message: 'Failed to upload envs to Zephyr' }); ze_log.snapshot('Build successfully deployed.'); } export { zeEnableSnapshotOnPages }; //# sourceMappingURL=ze-enable-snapshot-on-pages.mjs.map