Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

requireDatabaseInstance.js 1.2KB

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.requireDatabaseInstance = exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE = void 0;
  4. const clc = require("colorette");
  5. const error_1 = require("./error");
  6. const getDefaultDatabaseInstance_1 = require("./getDefaultDatabaseInstance");
  7. exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE = `It looks like you haven't created a Realtime Database instance in this project before. Please run ${clc.bold(clc.underline("firebase init database"))} to create your default Realtime Database instance.`;
  8. async function requireDatabaseInstance(options) {
  9. if (options.instance) {
  10. return;
  11. }
  12. let instance;
  13. try {
  14. instance = await (0, getDefaultDatabaseInstance_1.getDefaultDatabaseInstance)(options);
  15. }
  16. catch (err) {
  17. throw new error_1.FirebaseError(`Failed to get details for project: ${options.project}.`, {
  18. original: err,
  19. });
  20. }
  21. if (instance === "") {
  22. throw new error_1.FirebaseError(exports.MISSING_DEFAULT_INSTANCE_ERROR_MESSAGE);
  23. }
  24. options.instance = instance;
  25. }
  26. exports.requireDatabaseInstance = requireDatabaseInstance;