@niledatabase/server 2.2.0-alpha.0 → 2.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import syncFetch from 'sync-fetch';
2
1
  import 'dotenv/config';
3
2
  import isEmpty from 'lodash-es/isEmpty';
4
3
  import isObject from 'lodash-es/isObject';
@@ -679,55 +678,68 @@ var Config = /*#__PURE__*/function () {
679
678
  url.searchParams.set('databaseName', databaseName);
680
679
  }
681
680
  info(url.href);
682
- res = syncFetch(url, {
681
+ _context.next = 11;
682
+ return fetch(url, {
683
683
  headers: {
684
684
  Authorization: "Bearer " + getInfoBearer({
685
685
  config: config
686
686
  })
687
687
  }
688
688
  });
689
+ case 11:
690
+ res = _context.sent;
689
691
  possibleError = res.clone();
690
- try {
691
- json = res.json();
692
- if (res.status === 404) {
693
- info('is the configured databaseName correct?');
694
- }
695
- if (json.status && json.status !== 'READY') {
696
- database = {
697
- message: 'Database is not ready yet'
698
- };
699
- } else {
700
- database = json;
701
- }
702
- } catch (e) {
703
- message = possibleError.text();
704
- error(message);
692
+ _context.prev = 13;
693
+ _context.next = 16;
694
+ return res.json();
695
+ case 16:
696
+ json = _context.sent;
697
+ if (res.status === 404) {
698
+ info('is the configured databaseName correct?');
699
+ }
700
+ if (json.status && json.status !== 'READY') {
705
701
  database = {
706
- message: message
702
+ message: 'Database is not ready yet'
707
703
  };
704
+ } else {
705
+ database = json;
708
706
  }
707
+ _context.next = 28;
708
+ break;
709
+ case 21:
710
+ _context.prev = 21;
711
+ _context.t0 = _context["catch"](13);
712
+ _context.next = 25;
713
+ return possibleError.text();
714
+ case 25:
715
+ message = _context.sent;
716
+ error(message);
717
+ database = {
718
+ message: message
719
+ };
720
+ case 28:
709
721
  if (!(!host || !_this.databaseName || !_this.databaseId)) {
710
- _context.next = 23;
722
+ _context.next = 39;
711
723
  break;
712
724
  }
713
725
  info('[fetched database]', database);
714
726
  if (!(process.env.NODE_ENV !== 'TEST')) {
715
- _context.next = 23;
727
+ _context.next = 39;
716
728
  break;
717
729
  }
718
730
  if (!('message' in database)) {
719
- _context.next = 22;
731
+ _context.next = 38;
720
732
  break;
721
733
  }
722
734
  if (!('statusCode' in database)) {
723
- _context.next = 21;
735
+ _context.next = 37;
724
736
  break;
725
737
  }
726
738
  error(database);
727
739
  throw new Error('HTTP error has occured');
728
- case 21:
740
+ case 37:
729
741
  throw new Error('Unable to auto-configure. Please set or remove NILEDB_API, NILEDB_NAME, and NILEDB_HOST in your .env file.');
730
- case 22:
742
+ case 38:
731
743
  if (typeof database === 'object') {
732
744
  _database = database, apiHost = _database.apiHost, dbHost = _database.dbHost, name = _database.name, id = _database.id;
733
745
  _this.databaseId = id;
@@ -738,7 +750,7 @@ var Config = /*#__PURE__*/function () {
738
750
  host = dburl.host;
739
751
  basePath = apiurl.origin;
740
752
  }
741
- case 23:
753
+ case 39:
742
754
  _this.api = new ApiConfig({
743
755
  basePath: basePath,
744
756
  cookieKey: (_config$api$cookieKey = config == null || (_config$api = config.api) == null ? void 0 : _config$api.cookieKey) != null ? _config$api$cookieKey : 'token',
@@ -755,11 +767,11 @@ var Config = /*#__PURE__*/function () {
755
767
  }, typeof (config == null ? void 0 : config.db) === 'object' ? config.db : {});
756
768
  info('[config set]', _this);
757
769
  return _context.abrupt("return", _this);
758
- case 27:
770
+ case 43:
759
771
  case "end":
760
772
  return _context.stop();
761
773
  }
762
- }, _callee);
774
+ }, _callee, null, [[13, 21]]);
763
775
  }));
764
776
  return function (_x) {
765
777
  return _ref2.apply(this, arguments);