@edirect/mongo 11.0.44 → 11.0.46
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/mongo",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.46",
|
|
4
4
|
"main": "./dist/src/index.js",
|
|
5
5
|
"types": "./dist/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@aws-sdk/credential-providers": "^3.975.0",
|
|
20
|
-
"@edirect/config": "^11.0.
|
|
20
|
+
"@edirect/config": "^11.0.46",
|
|
21
21
|
"@nestjs/common": "^11.1.12",
|
|
22
22
|
"aws4": "^1.13.2",
|
|
23
23
|
"mongodb": "^7.0.0",
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConnection = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
tslib_1.__exportStar(require("./mongo.module"), exports);
|
|
6
|
+
var mongo_providers_1 = require("./mongo.providers");
|
|
7
|
+
Object.defineProperty(exports, "getConnection", { enumerable: true, get: function () { return mongo_providers_1.getConnection; } });
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { ConnectOptions } from 'mongoose';
|
|
1
2
|
import { Provider } from '@nestjs/common';
|
|
3
|
+
import { ConfigService } from '@edirect/config';
|
|
4
|
+
export declare function getConnection(configService: ConfigService): Promise<{
|
|
5
|
+
uri: string;
|
|
6
|
+
options: ConnectOptions;
|
|
7
|
+
}>;
|
|
2
8
|
export declare const MongoProviders: Provider[];
|
|
3
9
|
//# sourceMappingURL=mongo.providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongo.providers.d.ts","sourceRoot":"","sources":["../../src/mongo.providers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mongo.providers.d.ts","sourceRoot":"","sources":["../../src/mongo.providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAY,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAShD,wBAAsB,aAAa,CAAC,aAAa,EAAE,aAAa;;;GAoB/D;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,EAcpC,CAAC"}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MongoProviders = void 0;
|
|
4
|
+
exports.getConnection = getConnection;
|
|
4
5
|
const mongoose_1 = require("mongoose");
|
|
5
6
|
const config_1 = require("@edirect/config");
|
|
6
7
|
const aws_1 = require("./aws");
|
|
7
8
|
const isNotProductionOrLive = (nodeEnv) => nodeEnv !== 'production' && nodeEnv !== 'live';
|
|
8
9
|
const mongoUrl = (configService) => configService.get('MONGO_URL') ?? configService.get('MONGODB_URI');
|
|
10
|
+
async function getConnection(configService) {
|
|
11
|
+
const connectionString = mongoUrl(configService);
|
|
12
|
+
if (!connectionString)
|
|
13
|
+
throw new Error('MongoDB connection string is not defined');
|
|
14
|
+
const options = {};
|
|
15
|
+
// Always use dynamic AWS credential provider for MongoDB-AWS mechanism
|
|
16
|
+
if ((connectionString ?? '').includes('MONGODB-AWS')) {
|
|
17
|
+
options.authMechanismProperties = {
|
|
18
|
+
// This will provide rotating, always-fresh AWS credentials via IRSA
|
|
19
|
+
AWS_CREDENTIAL_PROVIDER: (0, aws_1.getMongoAwsCredentialProvider)(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Pool sizing for dev/test only
|
|
23
|
+
if (isNotProductionOrLive(configService.get('NODE_ENV'))) {
|
|
24
|
+
options.minPoolSize = 0;
|
|
25
|
+
options.maxPoolSize = 10;
|
|
26
|
+
}
|
|
27
|
+
return { uri: connectionString, options };
|
|
28
|
+
}
|
|
9
29
|
exports.MongoProviders = [
|
|
10
30
|
{
|
|
11
31
|
provide: 'MONGO_CONNECTION',
|
|
12
32
|
useFactory: async (configService) => {
|
|
13
|
-
const
|
|
14
|
-
if (!connectionString)
|
|
15
|
-
throw new Error('MongoDB connection string is not defined');
|
|
16
|
-
const options = {};
|
|
17
|
-
// Always use dynamic AWS credential provider for MongoDB-AWS mechanism
|
|
18
|
-
if ((connectionString ?? '').includes('MONGODB-AWS')) {
|
|
19
|
-
options.authMechanismProperties = {
|
|
20
|
-
// This will provide rotating, always-fresh AWS credentials via IRSA
|
|
21
|
-
AWS_CREDENTIAL_PROVIDER: (0, aws_1.getMongoAwsCredentialProvider)(),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
// Pool sizing for dev/test only
|
|
25
|
-
if (isNotProductionOrLive(configService.get('NODE_ENV'))) {
|
|
26
|
-
options.minPoolSize = 0;
|
|
27
|
-
options.maxPoolSize = 10;
|
|
28
|
-
}
|
|
33
|
+
const { uri, options } = await getConnection(configService);
|
|
29
34
|
try {
|
|
30
|
-
return await (0, mongoose_1.connect)(
|
|
35
|
+
return await (0, mongoose_1.connect)(uri, options);
|
|
31
36
|
}
|
|
32
37
|
catch (err) {
|
|
33
38
|
console.error('[mongo] Failed to connect to MongoDB:', err);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/mongo",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.46",
|
|
4
4
|
"packageScope": "@edirect",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"mongodb": "^7.0.0",
|
|
24
24
|
"mongoose": "^9.1.5",
|
|
25
25
|
"tslib": "^2.8.1",
|
|
26
|
-
"@edirect/config": "11.0.
|
|
26
|
+
"@edirect/config": "11.0.46"
|
|
27
27
|
},
|
|
28
28
|
"nx": {
|
|
29
29
|
"name": "@edirect/mongo",
|