index.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * @license
  5. * Copyright 2021 Google Inc.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. Object.defineProperty(exports, "__esModule", { value: true });
  20. exports.getFunctions = exports.TaskQueue = exports.Functions = void 0;
  21. /**
  22. * Firebase Functions service.
  23. *
  24. * @packageDocumentation
  25. */
  26. const app_1 = require("../app");
  27. const functions_1 = require("./functions");
  28. var functions_2 = require("./functions");
  29. Object.defineProperty(exports, "Functions", { enumerable: true, get: function () { return functions_2.Functions; } });
  30. Object.defineProperty(exports, "TaskQueue", { enumerable: true, get: function () { return functions_2.TaskQueue; } });
  31. /**
  32. * Gets the {@link Functions} service for the default app
  33. * or a given app.
  34. *
  35. * `getFunctions()` can be called with no arguments to access the default
  36. * app's `Functions` service or as `getFunctions(app)` to access the
  37. * `Functions` service associated with a specific app.
  38. *
  39. * @example
  40. * ```javascript
  41. * // Get the `Functions` service for the default app
  42. * const defaultFunctions = getFunctions();
  43. * ```
  44. *
  45. * @example
  46. * ```javascript
  47. * // Get the `Functions` service for a given app
  48. * const otherFunctions = getFunctions(otherApp);
  49. * ```
  50. *
  51. * @param app - Optional app for which to return the `Functions` service.
  52. * If not provided, the default `Functions` service is returned.
  53. *
  54. * @returns The default `Functions` service if no app is provided, or the `Functions`
  55. * service associated with the provided app.
  56. */
  57. function getFunctions(app) {
  58. if (typeof app === 'undefined') {
  59. app = (0, app_1.getApp)();
  60. }
  61. const firebaseApp = app;
  62. return firebaseApp.getOrInitService('functions', (app) => new functions_1.Functions(app));
  63. }
  64. exports.getFunctions = getFunctions;