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.getExtensions = exports.Runtime = exports.Extensions = void 0;
  21. /**
  22. * Firebase Extensions service.
  23. *
  24. * @packageDocumentation
  25. */
  26. const app_1 = require("../app");
  27. const extensions_1 = require("./extensions");
  28. var extensions_2 = require("./extensions");
  29. Object.defineProperty(exports, "Extensions", { enumerable: true, get: function () { return extensions_2.Extensions; } });
  30. Object.defineProperty(exports, "Runtime", { enumerable: true, get: function () { return extensions_2.Runtime; } });
  31. /**
  32. * Gets the {@link Extensions} service for the default app
  33. * or a given app.
  34. *
  35. * `getExtensions()` can be called with no arguments to access the default
  36. * app's `Extensions` service or as `getExtensions(app)` to access the
  37. * `Extensions` service associated with a specific app.
  38. *
  39. * @example
  40. * ```javascript
  41. * // Get the `Extensions` service for the default app
  42. * const defaultExtensions = getExtensions();
  43. * ```
  44. *
  45. * @example
  46. * ```javascript
  47. * // Get the `Extensions` service for a given app
  48. * const otherExtensions = getExtensions(otherApp);
  49. * ```
  50. *
  51. * @param app - Optional app for which to return the `Extensions` service.
  52. * If not provided, the default `Extensions` service is returned.
  53. *
  54. * @returns The default `Extensions` service if no app is provided, or the `Extensions`
  55. * service associated with the provided app.
  56. */
  57. function getExtensions(app) {
  58. if (typeof app === 'undefined') {
  59. app = (0, app_1.getApp)();
  60. }
  61. const firebaseApp = app;
  62. return firebaseApp.getOrInitService('extensions', (app) => new extensions_1.Extensions(app));
  63. }
  64. exports.getExtensions = getExtensions;