nexus-backend 1.0.9 → 1.1.0

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.
package/dist/index.d.mts CHANGED
@@ -27,6 +27,8 @@ interface MongoConfig {
27
27
  password: string;
28
28
  cluster: string;
29
29
  dbName: string;
30
+ shards: [string, string, string];
31
+ replicaSet: string;
30
32
  }
31
33
 
32
34
  declare const connectMongoDb: (config: MongoConfig) => Promise<boolean>;
package/dist/index.d.ts CHANGED
@@ -27,6 +27,8 @@ interface MongoConfig {
27
27
  password: string;
28
28
  cluster: string;
29
29
  dbName: string;
30
+ shards: [string, string, string];
31
+ replicaSet: string;
30
32
  }
31
33
 
32
34
  declare const connectMongoDb: (config: MongoConfig) => Promise<boolean>;
package/dist/index.js CHANGED
@@ -10360,15 +10360,16 @@ var requiredEnv = (value, key) => {
10360
10360
  // src/config/mongoConfig.ts
10361
10361
  var import_mongoose = __toESM(require("mongoose"));
10362
10362
  var connectMongoDb = async (config) => {
10363
- const { subDomain, userName, password, cluster, dbName } = config;
10364
- const srvURL = `mongodb+srv://${userName}:${password}@${cluster.toLowerCase()}.${subDomain}.mongodb.net/${dbName}?retryWrites=true&w=majority&appName=${cluster.toLowerCase()}`;
10363
+ const { subDomain, userName, password, cluster, dbName, shards, replicaSet } = config;
10364
+ const hosts = shards.map((s) => `${s}.${subDomain}.mongodb.net:27017`).join(",");
10365
+ const uri = `mongodb://${userName}:${password}@${hosts}/${dbName}?ssl=true&replicaSet=${replicaSet}&authSource=admin&appName=${cluster}`;
10365
10366
  try {
10366
- console.log("Trying +srv connection...");
10367
- await import_mongoose.default.connect(srvURL);
10367
+ console.log("Connecting to MongoDB...");
10368
+ await import_mongoose.default.connect(uri);
10368
10369
  console.log("Connected to MongoDB Atlas");
10369
10370
  return true;
10370
10371
  } catch (err) {
10371
- console.error("+srv connection failed:", err.message);
10372
+ console.error("Connection failed:", err.message);
10372
10373
  return false;
10373
10374
  }
10374
10375
  };