isAtlas.js 371 B

123456789101112
  1. 'use strict';
  2. module.exports = function isAtlas(topologyDescription) {
  3. if (topologyDescription == null ||
  4. topologyDescription.constructor.name !== 'TopologyDescription') {
  5. return false;
  6. }
  7. const hostnames = Array.from(topologyDescription.servers.keys());
  8. return hostnames.length > 0 &&
  9. hostnames.every(host => host.endsWith('.mongodb.net:27017'));
  10. };