ml-testing-toolkit 18.13.0 → 18.13.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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
  # Changelog: [mojaloop/thirdparty-api-svc](https://github.com/mojaloop/thirdparty-api-svc)
2
+ ### [18.13.1](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.13.0...v18.13.1) (2025-07-30)
3
+
4
+
5
+ ### Chore
6
+
7
+ * add ability to pass mongodb params ([#330](https://github.com/mojaloop/ml-testing-toolkit/issues/330)) ([d071616](https://github.com/mojaloop/ml-testing-toolkit/commit/d071616e02f06f9d110e7c3c3673f440e71e4043))
8
+
2
9
  ## [18.13.0](https://github.com/mojaloop/ml-testing-toolkit/compare/v18.12.4...v18.13.0) (2025-07-30)
3
10
 
4
11
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ml-testing-toolkit",
3
3
  "description": "Testing Toolkit for Mojaloop implementations",
4
- "version": "18.13.0",
4
+ "version": "18.13.1",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Vijaya Kumar Guthi, ModusBox Inc. ",
7
7
  "contributors": [
@@ -90,6 +90,7 @@
90
90
  "atob": "2.1.2",
91
91
  "axios": "1.11.0",
92
92
  "chai": "4.4.1",
93
+ "connection-string": "^4.4.0",
93
94
  "cookie-parser": "1.4.7",
94
95
  "cookies": "0.9.1",
95
96
  "cors": "2.8.5",
@@ -107,7 +108,6 @@
107
108
  "json-rules-engine": "7.3.1",
108
109
  "jsonwebtoken": "9.0.2",
109
110
  "lodash": "4.17.21",
110
- "mongo-uri-builder": "4.0.0",
111
111
  "mongoose": "8.16.5",
112
112
  "multer": "2.0.2",
113
113
  "mustache": "4.2.0",
@@ -19,7 +19,8 @@
19
19
  "USER": "ttk",
20
20
  "PASSWORD": "ttk@123",
21
21
  "DATABASE": "admin",
22
- "CONNECTION_STRING": null
22
+ "CONNECTION_STRING": null,
23
+ "PARAMS": {}
23
24
  },
24
25
  "METRICS": {
25
26
  "timeout": 5000,
@@ -30,20 +30,35 @@
30
30
  'use strict'
31
31
 
32
32
  const mongoDBWrapper = require('../models/mongoDBWrapper')
33
- const MongoUriBuilder = require('mongo-uri-builder')
33
+ const { ConnectionString } = require('connection-string')
34
+ const Logger = require('@mojaloop/central-services-logger')
34
35
 
35
36
  let conn
36
37
  const getConnection = async () => {
37
38
  if (!conn) {
38
39
  const Config = require('../../config')
39
40
  const systemConfig = Config.getSystemConfig()
40
- const connectionString = systemConfig.DB.CONNECTION_STRING || MongoUriBuilder({
41
- username: encodeURIComponent(systemConfig.DB.USER),
42
- password: encodeURIComponent(systemConfig.DB.PASSWORD),
43
- host: systemConfig.DB.HOST,
44
- port: systemConfig.DB.PORT,
45
- database: systemConfig.DB.DATABASE
41
+ let params = systemConfig.DB.PARAMS || {}
42
+ if (typeof params === 'string') {
43
+ try {
44
+ params = JSON.parse(params)
45
+ } catch (e) {
46
+ params = {}
47
+ }
48
+ }
49
+ const csMongoDBObj = new ConnectionString()
50
+ csMongoDBObj.setDefaults({
51
+ protocol: 'mongodb',
52
+ hosts: [{ name: systemConfig.DB.HOST, port: systemConfig.DB.PORT }],
53
+ user: systemConfig.DB.USER,
54
+ password: systemConfig.DB.PASSWORD,
55
+ path: [systemConfig.DB.DATABASE],
56
+ params
46
57
  })
58
+ const connectionString = systemConfig.DB.CONNECTION_STRING || csMongoDBObj.toString()
59
+ const safeConnectionString = connectionString.replace(/(\/\/)(.*):(.*)@/, '$1****:****@')
60
+ Logger.info(`Connecting to MongoDB with connection string: ${safeConnectionString}`)
61
+
47
62
  conn = await mongoDBWrapper.connect(connectionString, {
48
63
  useNewUrlParser: true,
49
64
  useUnifiedTopology: true