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

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var syncFetch = require('sync-fetch');
6
5
  require('dotenv/config');
7
6
  var isEmpty = require('lodash/isEmpty');
8
7
  var isObject = require('lodash/isObject');
@@ -683,51 +682,64 @@ var Config = /*#__PURE__*/function () {
683
682
  url.searchParams.set('databaseName', databaseName);
684
683
  }
685
684
  info(url.href);
686
- res = syncFetch(url, {
685
+ _context.next = 11;
686
+ return fetch(url, {
687
687
  headers: {
688
688
  Authorization: "Bearer " + getInfoBearer({
689
689
  config: config
690
690
  })
691
691
  }
692
692
  });
693
+ case 11:
694
+ res = _context.sent;
693
695
  possibleError = res.clone();
694
- try {
695
- json = res.json();
696
- if (res.status === 404) {
697
- info('is the configured databaseName correct?');
698
- }
699
- if (json.status && json.status !== 'READY') {
700
- database = {
701
- message: 'Database is not ready yet'
702
- };
703
- } else {
704
- database = json;
705
- }
706
- } catch (e) {
707
- message = possibleError.text();
708
- error(message);
696
+ _context.prev = 13;
697
+ _context.next = 16;
698
+ return res.json();
699
+ case 16:
700
+ json = _context.sent;
701
+ if (res.status === 404) {
702
+ info('is the configured databaseName correct?');
703
+ }
704
+ if (json.status && json.status !== 'READY') {
709
705
  database = {
710
- message: message
706
+ message: 'Database is not ready yet'
711
707
  };
708
+ } else {
709
+ database = json;
712
710
  }
711
+ _context.next = 28;
712
+ break;
713
+ case 21:
714
+ _context.prev = 21;
715
+ _context.t0 = _context["catch"](13);
716
+ _context.next = 25;
717
+ return possibleError.text();
718
+ case 25:
719
+ message = _context.sent;
720
+ error(message);
721
+ database = {
722
+ message: message
723
+ };
724
+ case 28:
713
725
  if (!(!host || !_this.databaseName || !_this.databaseId)) {
714
- _context.next = 23;
726
+ _context.next = 39;
715
727
  break;
716
728
  }
717
729
  info('[fetched database]', database);
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);