Skip to content

Commit 4f3cbca

Browse files
committed
Merge branch 'develop'
2 parents 1dabbde + 0408820 commit 4f3cbca

File tree

12 files changed

+87
-66
lines changed

12 files changed

+87
-66
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "soajs.core.modules",
33
"description": "SOAJS core modules package",
4-
"version": "5.2.15",
4+
"version": "5.2.16",
55
"author": {
66
"name": "soajs team",
77
"email": "team@soajs.org"
@@ -50,8 +50,8 @@
5050
"install": "0.13.0",
5151
"jsonschema": "1.5.0",
5252
"lodash": "4.17.21",
53-
"mongodb": "6.16.0",
54-
"nodemailer": "6.10.1",
53+
"mongodb": "6.20.0",
54+
"nodemailer": "7.0.6",
5555
"object-hash": "3.0.0",
5656
"soajs.core.libs": "1.2.1"
5757
}

soajs.core/mail/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let nodemailer = require("nodemailer");
1414

1515
let mailer = function (configuration) {
1616
let transport;
17-
17+
1818
//if no conf, switch to direct transport driver with default options
1919
if (!configuration) {
2020
transport = config.transport.default.options;
@@ -30,7 +30,7 @@ let mailer = function (configuration) {
3030
}
3131
throw new Error("transport error: " + err.join(" - "));
3232
}
33-
33+
3434
//check type and use corresponding transport driver
3535
switch (configuration.type.toLowerCase()) {
3636
case 'smtp':
@@ -42,7 +42,7 @@ let mailer = function (configuration) {
4242
break;
4343
}
4444
}
45-
45+
4646
//initialize the transporter with driver from above
4747
this.transporter = nodemailer.createTransport(transport);
4848
};
@@ -58,9 +58,12 @@ mailer.prototype.send = function (mailOptions, callback) {
5858
}
5959
return callback(new Error("mailOptions error: " + err.join(" - ")));
6060
}
61-
61+
6262
//tell the driver to send the mail
63-
this.transporter.sendMail(mailOptions, callback);
63+
this.transporter
64+
.sendMail(mailOptions)
65+
.then((info) => { callback(null, info); })
66+
.catch((error) => { callback(error, null); });
6467
};
6568

6669
module.exports = mailer;

test/data/import.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#!/bin/bash
22

33
pushd ./provision
4-
mongo ./environment.js
5-
mongo ./oauth.js
6-
mongo ./product.js
7-
mongo ./tenant.js
8-
mongo ./resources.js
9-
mongo ./customRegistry.js
4+
5+
mongosh ./environment.js
6+
mongosh ./oauth.js
7+
mongosh ./product.js
8+
mongosh ./tenant.js
9+
mongosh ./resources.js
10+
mongosh ./customRegistry.js
11+
1012
popd
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
let provDb = db.getSiblingDB('core_provision');
22

3-
let files = listFiles('./customRegistry');
4-
for (let i = 0; i < files.length; i++) {
5-
load(files[i].name);
6-
}
3+
load('./customRegistry/test.js');
74

85
provDb.custom_registry.drop();
96

107
let records = [];
118
let index = 0;
129

13-
records.push(customRegistry[index++]);
10+
if (typeof customRegistry !== 'undefined' && customRegistry.length > 0) {
11+
records.push(customRegistry[index++]);
12+
}
1413

15-
provDb.custom_registry.insert(records);
14+
// Use insertMany() which is the modern method for bulk inserts
15+
if (records.length > 0) {
16+
provDb.custom_registry.insertMany(records);
17+
}
1618

1719
/* Indexes for products */
18-
provDb.custom_registry.createIndex({ code: 1 }, { unique: true });
20+
provDb.custom_registry.createIndex({ code: 1 }, { unique: true });

test/data/provision/environment.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
let provDb = db.getSiblingDB('core_provision');
22
provDb.dropDatabase();
33

4-
let files = listFiles('./environments');
5-
for (let i = 0; i < files.length; i++) {
6-
load(files[i].name);
7-
}
4+
load('./environments/dev.js');
5+
load('./environments/test.js');
86

97
provDb.environment.drop();
108

9+
// Define the records from the loaded files
1110
let records = [];
12-
records.push(dev);
13-
records.push(test);
14-
provDb.environment.insert(records);
11+
if (typeof dev !== 'undefined') {
12+
records.push(dev);
13+
}
14+
if (typeof test !== 'undefined') {
15+
records.push(test);
16+
}
17+
18+
// Insert the records
19+
if (records.length > 0) {
20+
provDb.environment.insertMany(records);
21+
}
1522

16-
/* Indexes for products */
17-
provDb.environment.createIndex({ code: 1 }, { unique: true });
23+
// Create an index on the 'code' field
24+
provDb.environment.createIndex({ code: 1 }, { unique: true });

test/data/provision/oauth.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
let provDb = db.getSiblingDB('core_provision');
22

3-
/* oAuth URAC */
4-
let files = listFiles('./oauth');
5-
for (let i = 0; i < files.length; i++) {
6-
load(files[i].name);
7-
}
3+
load('./oauth/oauthuser.js');
84

95
provDb.oauth_urac.drop();
106

117
let records = [];
12-
records.push(oauthuser);
13-
provDb.oauth_urac.insert(records);
8+
if (typeof oauthuser !== 'undefined') {
9+
records.push(oauthuser);
10+
}
11+
12+
// use insertMany() for inserting an array of records
13+
if (records.length > 0) {
14+
provDb.oauth_urac.insertMany(records);
15+
}
File renamed without changes.

test/data/provision/product.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
let provDb = db.getSiblingDB('core_provision');
2-
//provDb.dropDatabase();
32

4-
/* Tenants */
5-
let files = listFiles('./products');
6-
for (let i = 0; i < files.length; i++) {
7-
load(files[i].name);
8-
}
3+
load('./products/testProduct.js');
94

105
provDb.products.drop();
116

127
let records = [];
13-
records.push(testProduct);
14-
provDb.products.insert(records);
8+
if (typeof testProduct !== 'undefined') {
9+
records.push(testProduct);
10+
}
1511

12+
// Use insertMany() for inserting an array of records
13+
if (records.length > 0) {
14+
provDb.products.insertMany(records);
15+
}
1616

1717
/* Indexes for products */
1818
provDb.products.createIndex({ code: 1 }, { unique: true });
19-
provDb.products.createIndex({ 'packages.code': 1 });
19+
provDb.products.createIndex({ 'packages.code': 1 });
File renamed without changes.

test/data/provision/resources.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
let provDb = db.getSiblingDB('core_provision');
22

3-
let files = listFiles('./resources');
4-
for (let i = 0; i < files.length; i++) {
5-
load(files[i].name);
6-
}
3+
load('./resources/resources.js');
74

85
provDb.resources.drop();
96

107
let records = [];
118
let index = 0;
129

13-
records.push(resources[index++]);
14-
records.push(resources[index++]);
15-
records.push(resources[index++]);
16-
records.push(resources[index++]);
17-
provDb.resources.insert(records);
10+
// Push the loaded objects to the array
11+
if (typeof resources !== 'undefined' && resources.length > 0) {
12+
records.push(resources[index++]);
13+
records.push(resources[index++]);
14+
records.push(resources[index++]);
15+
records.push(resources[index++]);
16+
}
1817

19-
/* Indexes for products */
20-
provDb.resources.createIndex({ code: 1 }, { unique: true });
18+
// Use insertMany() which is the modern method for bulk inserts
19+
if (records.length > 0) {
20+
provDb.resources.insertMany(records);
21+
}

0 commit comments

Comments
 (0)