@equinor/fusion-framework-cli
Version:
--- title: Fusion Framework CLI ---
35 lines • 1.52 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import fetch from 'node-fetch';
/**
* Make sure the app is registerred in the app-service
* @param endpoint <string> The endpoint to make a call to
*/
export const isAppRegistered = (endpoint) => __awaiter(void 0, void 0, void 0, function* () {
const requestApp = yield fetch(endpoint, {
method: 'HEAD',
headers: {
Authorization: `Bearer ${process.env.FUSION_TOKEN}`,
},
});
/** Assume that ok response asserts that app exists */
if (requestApp.ok) {
return true;
}
if (requestApp.status === 404) {
return false;
}
if (requestApp.status === 410) {
throw Error('App is deleted.');
}
const data = yield requestApp.json();
throw Error('Custom Fusion error, see cause.', { cause: data });
});
//# sourceMappingURL=isAppRegistered.js.map