Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.functionsProxy = void 0;
  4. const lodash_1 = require("lodash");
  5. const proxy_1 = require("./proxy");
  6. const projectUtils_1 = require("../projectUtils");
  7. const registry_1 = require("../emulator/registry");
  8. const types_1 = require("../emulator/types");
  9. const functionsEmulator_1 = require("../emulator/functionsEmulator");
  10. const error_1 = require("../error");
  11. function functionsProxy(options) {
  12. return (rewrite) => {
  13. return new Promise((resolve) => {
  14. const projectId = (0, projectUtils_1.needProjectId)(options);
  15. if (!("function" in rewrite)) {
  16. throw new error_1.FirebaseError(`A non-function rewrite cannot be used in functionsProxy`, {
  17. exit: 2,
  18. });
  19. }
  20. let functionId;
  21. let region;
  22. if (typeof rewrite.function === "string") {
  23. functionId = rewrite.function;
  24. region = rewrite.region || "us-central1";
  25. }
  26. else {
  27. functionId = rewrite.function.functionId;
  28. region = rewrite.function.region || "us-central1";
  29. }
  30. let url = `https://${region}-${projectId}.cloudfunctions.net/${functionId}`;
  31. let destLabel = "live";
  32. if ((0, lodash_1.includes)(options.targets, "functions")) {
  33. destLabel = "local";
  34. if (registry_1.EmulatorRegistry.isRunning(types_1.Emulators.FUNCTIONS)) {
  35. url = functionsEmulator_1.FunctionsEmulator.getHttpFunctionUrl(projectId, functionId, region);
  36. }
  37. }
  38. resolve((0, proxy_1.proxyRequestHandler)(url, `${destLabel} Function ${region}/${functionId}`));
  39. });
  40. };
  41. }
  42. exports.functionsProxy = functionsProxy;