picker-db 3.5.0 → 3.6.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## v3.6.0
6
+ ### Added
7
+ * Mongo Atlas Connection: Added configuration for connection with MongoAtlas database
@@ -1,3 +1,5 @@
1
+ require("./typedef");
2
+
1
3
  const mongoose = require("mongoose");
2
4
  const _ = require("lodash");
3
5
 
@@ -9,18 +11,7 @@ const logger = require("../Logger");
9
11
  class MongoDB {
10
12
  /**
11
13
  * Sets up the configuration for the mongo connection
12
- * @param {object} config
13
- * @param {string} config.dbName
14
- * @param {boolean} [config.isLoggingEnabled]
15
- * @param {boolean} [config.isDebugEnabled]
16
- * @param {object} config.auth
17
- * @param {string} config.auth.username
18
- * @param {string} config.auth.password
19
- * @param {string} [config.auth.host]
20
- * @param {string} [config.auth.port]
21
- * @param {string} [config.auth.environment]
22
- * @param {boolean} [config.useMongoClient]
23
- * @param {boolean} [config.useUnifiedTopology]
14
+ * @param {MongoConfig} config
24
15
  */
25
16
  constructor (config = {}) {
26
17
  this.config = _.defaults(
@@ -45,15 +36,15 @@ class MongoDB {
45
36
 
46
37
  /**
47
38
  * Returns connection uri based on environment
48
- * @param {object} auth
49
- * @param {string} auth.username
50
- * @param {string} auth.password
51
- * @param {string} [auth.host]
52
- * @param {string} [auth.port]
39
+ * @param {MongoAuth} auth
40
+ * @returns {string}
53
41
  */
54
42
  getUri (auth) {
55
43
  let uri = "";
56
44
  switch (auth.environment) {
45
+ case "atlas":
46
+ uri = auth.dbUri;
47
+ break;
57
48
  case "local":
58
49
  uri = `mongodb://${auth.host}:${auth.port}/${this.config.dbName}`;
59
50
  break;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @typedef MongoConfig
3
+ * @property {string} dbName
4
+ * @property {boolean} [isLoggingEnabled]
5
+ * @property {boolean} [isDebugEnabled]
6
+ * @property {boolean} [useMongoClient]
7
+ * @property {boolean} [useUnifiedTopology]
8
+ * @property {MongoAuth} auth
9
+ */
10
+
11
+ /**
12
+ * @typedef MongoAuth
13
+ * @property {string} [environment]
14
+ * @property {string} [username]
15
+ * @property {string} [password]
16
+ * @property {string} [host]
17
+ * @property {string} [port]
18
+ * @property {string} [dbUri]
19
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "picker-db",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "Picker DB services",
5
5
  "main": "index.js",
6
6
  "scripts": {