Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

database-settings-get.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.command = void 0;
  4. const url_1 = require("url");
  5. const apiv2_1 = require("../apiv2");
  6. const command_1 = require("../command");
  7. const settings_1 = require("../database/settings");
  8. const types_1 = require("../emulator/types");
  9. const error_1 = require("../error");
  10. const database_1 = require("../management/database");
  11. const api_1 = require("../database/api");
  12. const requirePermissions_1 = require("../requirePermissions");
  13. const commandUtils_1 = require("../emulator/commandUtils");
  14. const requireDatabaseInstance_1 = require("../requireDatabaseInstance");
  15. const utils = require("../utils");
  16. exports.command = new command_1.Command("database:settings:get <path>")
  17. .description("read the realtime database setting at path")
  18. .option("--instance <instance>", "use the database <instance>.firebaseio.com (if omitted, uses default database instance)")
  19. .help(settings_1.HELP_TEXT)
  20. .before(requirePermissions_1.requirePermissions, ["firebasedatabase.instances.get"])
  21. .before(requireDatabaseInstance_1.requireDatabaseInstance)
  22. .before(database_1.populateInstanceDetails)
  23. .before(commandUtils_1.warnEmulatorNotSupported, types_1.Emulators.DATABASE)
  24. .action(async (path, options) => {
  25. if (!settings_1.DATABASE_SETTINGS.has(path)) {
  26. throw new error_1.FirebaseError(settings_1.INVALID_PATH_ERROR, { exit: 1 });
  27. }
  28. const u = new url_1.URL(utils.getDatabaseUrl((0, api_1.realtimeOriginOrCustomUrl)(options.instanceDetails.databaseUrl), options.instance, `/.settings/${path}.json`));
  29. const c = new apiv2_1.Client({ urlPrefix: u.origin, auth: true });
  30. let res;
  31. try {
  32. res = await c.get(u.pathname);
  33. }
  34. catch (err) {
  35. throw new error_1.FirebaseError(`Unexpected error fetching configs at ${path}`, {
  36. exit: 2,
  37. original: err,
  38. });
  39. }
  40. if (typeof res.body === "object") {
  41. res.body = res.body.value;
  42. }
  43. utils.logSuccess(`For database instance ${options.instance}\n\t ${path} = ${res.body}`);
  44. });