firebase-functions
Version:
Firebase SDK for Cloud Functions
31 lines (30 loc) • 784 B
JavaScript
//#region src/common/api.ts
let globalRequiredAPIs = [];
/**
* Declare that this project requires a specific Google Cloud API to be enabled.
* @param api The API name, e.g. "secretmanager.googleapis.com"
* @param reason Optional reason why the API is needed.
*/
function requiresAPI(api, reason = "") {
if (!api || typeof api !== "string" || !api.endsWith(".googleapis.com")) {
throw new Error("requiresAPI: 'api' must be a non-empty string ending with '.googleapis.com'.");
}
globalRequiredAPIs.push({
api,
reason
});
}
/**
* @internal
*/
function getGlobalRequiredAPIs() {
return globalRequiredAPIs;
}
/**
* @internal
*/
function clearGlobalRequiredAPIs() {
globalRequiredAPIs = [];
}
//#endregion
export { clearGlobalRequiredAPIs, getGlobalRequiredAPIs, requiresAPI };