index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. let BSON = require('bson');
  3. const require_optional = require('optional-require')(require);
  4. const EJSON = require('./utils').retrieveEJSON();
  5. try {
  6. // Attempt to grab the native BSON parser
  7. const BSONNative = require_optional('bson-ext');
  8. // If we got the native parser, use it instead of the
  9. // Javascript one
  10. if (BSONNative) {
  11. BSON = BSONNative;
  12. }
  13. } catch (err) {} // eslint-disable-line
  14. module.exports = {
  15. // Errors
  16. MongoError: require('./error').MongoError,
  17. MongoNetworkError: require('./error').MongoNetworkError,
  18. MongoParseError: require('./error').MongoParseError,
  19. MongoTimeoutError: require('./error').MongoTimeoutError,
  20. MongoServerSelectionError: require('./error').MongoServerSelectionError,
  21. MongoWriteConcernError: require('./error').MongoWriteConcernError,
  22. // Core
  23. Connection: require('./connection/connection'),
  24. Server: require('./topologies/server'),
  25. ReplSet: require('./topologies/replset'),
  26. Mongos: require('./topologies/mongos'),
  27. Logger: require('./connection/logger'),
  28. Cursor: require('./cursor').CoreCursor,
  29. ReadPreference: require('./topologies/read_preference'),
  30. Sessions: require('./sessions'),
  31. BSON: BSON,
  32. EJSON: EJSON,
  33. Topology: require('./sdam/topology').Topology,
  34. // Raw operations
  35. Query: require('./connection/commands').Query,
  36. // Auth mechanisms
  37. MongoCredentials: require('./auth/mongo_credentials').MongoCredentials,
  38. defaultAuthProviders: require('./auth/defaultAuthProviders').defaultAuthProviders,
  39. MongoCR: require('./auth/mongocr'),
  40. X509: require('./auth/x509'),
  41. Plain: require('./auth/plain'),
  42. GSSAPI: require('./auth/gssapi'),
  43. ScramSHA1: require('./auth/scram').ScramSHA1,
  44. ScramSHA256: require('./auth/scram').ScramSHA256,
  45. // Utilities
  46. parseConnectionString: require('./uri_parser')
  47. };