@xnestjs/mongodb 1.7.0 → 1.8.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/README.md CHANGED
@@ -22,17 +22,16 @@ import { Module } from '@nestjs/common';
22
22
  import { MongoModule } from '@xnestjs/mongodb';
23
23
 
24
24
  @Module({
25
- imports: [
26
- MongodbModule.forRoot({
27
- useValue: {
28
- url: 'https://mydbserver:27017',
29
- database: 'test',
30
- },
31
- }),
32
- ],
25
+ imports: [
26
+ MongodbModule.forRoot({
27
+ useValue: {
28
+ url: 'https://mydbserver:27017',
29
+ database: 'test',
30
+ },
31
+ }),
32
+ ],
33
33
  })
34
- export class MyModule {
35
- }
34
+ export class MyModule {}
36
35
  ```
37
36
 
38
37
  ### Register async
@@ -45,29 +44,28 @@ import { Module } from '@nestjs/common';
45
44
  import { MongoModule } from '@xnestjs/mongodb';
46
45
 
47
46
  @Module({
48
- imports: [
49
- MongodbModule.forRootAsync({
50
- inject: [ConfigModule],
51
- useFactory: (config: ConfigService) => ({
52
- url: config.get('MONGODB_URL'),
53
- database: config.get('MONGODB_DATABASE'),
54
- }),
55
- }),
56
- ]
47
+ imports: [
48
+ MongodbModule.forRootAsync({
49
+ inject: [ConfigModule],
50
+ useFactory: (config: ConfigService) => ({
51
+ url: config.get('MONGODB_URL'),
52
+ database: config.get('MONGODB_DATABASE'),
53
+ }),
54
+ }),
55
+ ],
57
56
  })
58
- export class MyModule {
59
- }
57
+ export class MyModule {}
60
58
  ```
61
59
 
62
60
  ## Environment Variables
63
61
 
64
62
  The library supports configuration through environment variables. Environment variables below is accepted.
65
- All environment variables starts with prefix (MONGODB_). This can be configured while registering the module.
63
+ All environment variables starts with prefix (MONGODB\_). This can be configured while registering the module.
66
64
 
67
65
  <--- BEGIN env --->
68
66
 
69
67
  | Environment Variable | Type | Default | Description |
70
- |----------------------------------------|---------|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
68
+ | -------------------------------------- | ------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
71
69
  | MONGODB_URL | String | mongodb://localhost:27017 | URL to MongoDB server |
72
70
  | MONGODB_USERNAME | String | | The username for auth |
73
71
  | MONGODB_PASSWORD | String | | The password for auth |
@@ -8,49 +8,74 @@ const putil_varhelpers_1 = require("putil-varhelpers");
8
8
  function getMongodbConfig(moduleOptions, prefix = 'MONGODB_') {
9
9
  const options = (0, objects_1.clone)(moduleOptions);
10
10
  const env = node_process_1.default.env;
11
- options.url = options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
11
+ options.url =
12
+ options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
12
13
  options.timeoutMS = options.timeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'TIMEOUT']);
13
14
  options.replicaSet = options.replicaSet ?? env[prefix + 'REPLICA_SET'];
14
15
  options.tls = options.tls ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS']);
15
- options.tlsCertificateKeyFile = options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
16
- options.tlsCertificateKeyFilePassword = options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
16
+ options.tlsCertificateKeyFile =
17
+ options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
18
+ options.tlsCertificateKeyFilePassword =
19
+ options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
17
20
  options.tlsCAFile = options.tlsCAFile ?? env[prefix + 'TLS_CA_FILE'];
18
21
  options.tlsCRLFile = options.tlsCRLFile ?? env[prefix + 'TLS_CRL_FILE'];
19
22
  options.tlsAllowInvalidCertificates =
20
- options.tlsAllowInvalidCertificates ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
23
+ options.tlsAllowInvalidCertificates ??
24
+ (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
21
25
  options.tlsAllowInvalidCertificates =
22
- options.tlsAllowInvalidHostnames ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
23
- options.tlsInsecure = options.tlsInsecure ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_INSECURE']);
24
- options.connectTimeoutMS = options.connectTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'CONNECT_TIMEOUT']);
25
- options.socketTimeoutMS = options.socketTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SOCKET_TIMEOUT']);
26
+ options.tlsAllowInvalidHostnames ??
27
+ (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
28
+ options.tlsInsecure =
29
+ options.tlsInsecure ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_INSECURE']);
30
+ options.connectTimeoutMS =
31
+ options.connectTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'CONNECT_TIMEOUT']);
32
+ options.socketTimeoutMS =
33
+ options.socketTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SOCKET_TIMEOUT']);
26
34
  options.database = options.database ?? env[prefix + 'DATABASE'];
27
- options.srvMaxHosts = options.srvMaxHosts ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SRV_MAX_HOSTS']);
28
- options.maxPoolSize = options.minPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_POOL_SIZE']);
29
- options.minPoolSize = options.maxPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MIN_POOL_SIZE']);
30
- options.maxConnecting = options.maxConnecting ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_CONNECTING']);
31
- options.maxIdleTimeMS = options.maxIdleTimeMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_IDLE_TIME']);
32
- options.waitQueueTimeoutMS = options.waitQueueTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
33
- options.maxStalenessSeconds = options.maxStalenessSeconds ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_STALENESS_SECONDS']);
35
+ options.srvMaxHosts =
36
+ options.srvMaxHosts ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SRV_MAX_HOSTS']);
37
+ options.maxPoolSize =
38
+ options.minPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_POOL_SIZE']);
39
+ options.minPoolSize =
40
+ options.maxPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MIN_POOL_SIZE']);
41
+ options.maxConnecting =
42
+ options.maxConnecting ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_CONNECTING']);
43
+ options.maxIdleTimeMS =
44
+ options.maxIdleTimeMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_IDLE_TIME']);
45
+ options.waitQueueTimeoutMS =
46
+ options.waitQueueTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
47
+ options.maxStalenessSeconds =
48
+ options.maxStalenessSeconds ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_STALENESS_SECONDS']);
34
49
  if (!options.auth?.username) {
35
50
  options.auth = options.auth || {};
36
51
  options.auth.username = options.auth.username ?? env[prefix + 'USERNAME'];
37
52
  options.auth.password = options.auth.password ?? env[prefix + 'PASSWORD'];
38
53
  }
39
54
  options.authSource = options.authSource ?? env[prefix + 'AUTH_SOURCE'];
40
- options.localThresholdMS = options.localThresholdMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'LOCAL_THRESHOLD']);
55
+ options.localThresholdMS =
56
+ options.localThresholdMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'LOCAL_THRESHOLD']);
41
57
  options.serverSelectionTimeoutMS =
42
- options.serverSelectionTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
43
- options.minHeartbeatFrequencyMS = options.minHeartbeatFrequencyMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'HEARTBEAT_FREQUENCY']);
58
+ options.serverSelectionTimeoutMS ??
59
+ (0, putil_varhelpers_1.toInt)(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
60
+ options.minHeartbeatFrequencyMS =
61
+ options.minHeartbeatFrequencyMS ??
62
+ (0, putil_varhelpers_1.toInt)(env[prefix + 'HEARTBEAT_FREQUENCY']);
44
63
  options.appName = options.appName ?? env[prefix + 'APP_NAME'];
45
- options.retryReads = options.retryReads ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_READS']);
46
- options.retryWrites = options.retryWrites ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_WRITES']);
47
- options.directConnection = options.directConnection ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'DIRECT_CONNECTION']);
48
- options.loadBalanced = options.loadBalanced ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'LOAD_BALANCED']);
64
+ options.retryReads =
65
+ options.retryReads ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_READS']);
66
+ options.retryWrites =
67
+ options.retryWrites ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_WRITES']);
68
+ options.directConnection =
69
+ options.directConnection ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'DIRECT_CONNECTION']);
70
+ options.loadBalanced =
71
+ options.loadBalanced ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'LOAD_BALANCED']);
49
72
  options.noDelay = options.noDelay ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'NO_DELAY']);
50
- options.monitorCommands = options.monitorCommands ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'MONITOR_COMMANDS']);
73
+ options.monitorCommands =
74
+ options.monitorCommands ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'MONITOR_COMMANDS']);
51
75
  options.proxyHost = options.proxyHost ?? env[prefix + 'PROXY_HOST'];
52
76
  options.proxyPort = options.proxyPort ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'PROXY_PORT']);
53
77
  options.proxyUsername = options.proxyHost ?? env[prefix + 'PROXY_USERNAME'];
54
- options.proxyPassword = options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
78
+ options.proxyPassword =
79
+ options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
55
80
  return options;
56
81
  }
@@ -55,7 +55,11 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
55
55
  provide: token,
56
56
  inject: [constants_js_1.MONGODB_CONNECTION_OPTIONS],
57
57
  useFactory: async (connectionOptions) => {
58
- const mongoOptions = (0, objects_1.omit)(connectionOptions, ['url', 'database', 'lazyConnect']);
58
+ const mongoOptions = (0, objects_1.omit)(connectionOptions, [
59
+ 'url',
60
+ 'database',
61
+ 'lazyConnect',
62
+ ]);
59
63
  if (mongoOptions.auth && !mongoOptions.auth?.username)
60
64
  delete mongoOptions.auth;
61
65
  return new mongodb_1.MongoClient(connectionOptions.url, mongoOptions);
@@ -65,7 +69,9 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
65
69
  provide: dbToken,
66
70
  inject: [token, constants_js_1.MONGODB_CONNECTION_OPTIONS],
67
71
  useFactory: async (client, connectionOptions) => {
68
- return connectionOptions.database ? client.db(connectionOptions.database) : undefined;
72
+ return connectionOptions.database
73
+ ? client.db(connectionOptions.database)
74
+ : undefined;
69
75
  },
70
76
  },
71
77
  {
@@ -74,7 +80,9 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
74
80
  },
75
81
  {
76
82
  provide: common_1.Logger,
77
- useValue: typeof opts.logger === 'string' ? new common_1.Logger(opts.logger) : opts.logger,
83
+ useValue: typeof opts.logger === 'string'
84
+ ? new common_1.Logger(opts.logger)
85
+ : opts.logger,
78
86
  },
79
87
  ];
80
88
  return {
@@ -88,7 +96,12 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
88
96
  useValue: crypto.randomUUID(),
89
97
  },
90
98
  ],
91
- exports: [constants_js_1.MONGODB_CONNECTION_OPTIONS, token, dbToken, ...(metadata.exports ?? [])],
99
+ exports: [
100
+ constants_js_1.MONGODB_CONNECTION_OPTIONS,
101
+ token,
102
+ dbToken,
103
+ ...(metadata.exports ?? []),
104
+ ],
92
105
  };
93
106
  }
94
107
  /**
@@ -18,7 +18,8 @@ let MongodbHealthIndicator = class MongodbHealthIndicator {
18
18
  }
19
19
  async pingCheck(key, options) {
20
20
  const { HealthIndicatorService } = await Promise.resolve().then(() => tslib_1.__importStar(require('@nestjs/terminus')));
21
- this.healthIndicatorService = this.healthIndicatorService || new HealthIndicatorService();
21
+ this.healthIndicatorService =
22
+ this.healthIndicatorService || new HealthIndicatorService();
22
23
  const indicator = this.healthIndicatorService.check(key);
23
24
  let connection;
24
25
  try {
@@ -4,49 +4,74 @@ import { toBoolean, toInt } from 'putil-varhelpers';
4
4
  export function getMongodbConfig(moduleOptions, prefix = 'MONGODB_') {
5
5
  const options = clone(moduleOptions);
6
6
  const env = process.env;
7
- options.url = options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
7
+ options.url =
8
+ options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
8
9
  options.timeoutMS = options.timeoutMS ?? toInt(env[prefix + 'TIMEOUT']);
9
10
  options.replicaSet = options.replicaSet ?? env[prefix + 'REPLICA_SET'];
10
11
  options.tls = options.tls ?? toBoolean(env[prefix + 'TLS']);
11
- options.tlsCertificateKeyFile = options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
12
- options.tlsCertificateKeyFilePassword = options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
12
+ options.tlsCertificateKeyFile =
13
+ options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
14
+ options.tlsCertificateKeyFilePassword =
15
+ options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
13
16
  options.tlsCAFile = options.tlsCAFile ?? env[prefix + 'TLS_CA_FILE'];
14
17
  options.tlsCRLFile = options.tlsCRLFile ?? env[prefix + 'TLS_CRL_FILE'];
15
18
  options.tlsAllowInvalidCertificates =
16
- options.tlsAllowInvalidCertificates ?? toBoolean(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
19
+ options.tlsAllowInvalidCertificates ??
20
+ toBoolean(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
17
21
  options.tlsAllowInvalidCertificates =
18
- options.tlsAllowInvalidHostnames ?? toBoolean(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
19
- options.tlsInsecure = options.tlsInsecure ?? toBoolean(env[prefix + 'TLS_INSECURE']);
20
- options.connectTimeoutMS = options.connectTimeoutMS ?? toInt(env[prefix + 'CONNECT_TIMEOUT']);
21
- options.socketTimeoutMS = options.socketTimeoutMS ?? toInt(env[prefix + 'SOCKET_TIMEOUT']);
22
+ options.tlsAllowInvalidHostnames ??
23
+ toBoolean(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
24
+ options.tlsInsecure =
25
+ options.tlsInsecure ?? toBoolean(env[prefix + 'TLS_INSECURE']);
26
+ options.connectTimeoutMS =
27
+ options.connectTimeoutMS ?? toInt(env[prefix + 'CONNECT_TIMEOUT']);
28
+ options.socketTimeoutMS =
29
+ options.socketTimeoutMS ?? toInt(env[prefix + 'SOCKET_TIMEOUT']);
22
30
  options.database = options.database ?? env[prefix + 'DATABASE'];
23
- options.srvMaxHosts = options.srvMaxHosts ?? toInt(env[prefix + 'SRV_MAX_HOSTS']);
24
- options.maxPoolSize = options.minPoolSize ?? toInt(env[prefix + 'MAX_POOL_SIZE']);
25
- options.minPoolSize = options.maxPoolSize ?? toInt(env[prefix + 'MIN_POOL_SIZE']);
26
- options.maxConnecting = options.maxConnecting ?? toInt(env[prefix + 'MAX_CONNECTING']);
27
- options.maxIdleTimeMS = options.maxIdleTimeMS ?? toInt(env[prefix + 'MAX_IDLE_TIME']);
28
- options.waitQueueTimeoutMS = options.waitQueueTimeoutMS ?? toInt(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
29
- options.maxStalenessSeconds = options.maxStalenessSeconds ?? toInt(env[prefix + 'MAX_STALENESS_SECONDS']);
31
+ options.srvMaxHosts =
32
+ options.srvMaxHosts ?? toInt(env[prefix + 'SRV_MAX_HOSTS']);
33
+ options.maxPoolSize =
34
+ options.minPoolSize ?? toInt(env[prefix + 'MAX_POOL_SIZE']);
35
+ options.minPoolSize =
36
+ options.maxPoolSize ?? toInt(env[prefix + 'MIN_POOL_SIZE']);
37
+ options.maxConnecting =
38
+ options.maxConnecting ?? toInt(env[prefix + 'MAX_CONNECTING']);
39
+ options.maxIdleTimeMS =
40
+ options.maxIdleTimeMS ?? toInt(env[prefix + 'MAX_IDLE_TIME']);
41
+ options.waitQueueTimeoutMS =
42
+ options.waitQueueTimeoutMS ?? toInt(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
43
+ options.maxStalenessSeconds =
44
+ options.maxStalenessSeconds ?? toInt(env[prefix + 'MAX_STALENESS_SECONDS']);
30
45
  if (!options.auth?.username) {
31
46
  options.auth = options.auth || {};
32
47
  options.auth.username = options.auth.username ?? env[prefix + 'USERNAME'];
33
48
  options.auth.password = options.auth.password ?? env[prefix + 'PASSWORD'];
34
49
  }
35
50
  options.authSource = options.authSource ?? env[prefix + 'AUTH_SOURCE'];
36
- options.localThresholdMS = options.localThresholdMS ?? toInt(env[prefix + 'LOCAL_THRESHOLD']);
51
+ options.localThresholdMS =
52
+ options.localThresholdMS ?? toInt(env[prefix + 'LOCAL_THRESHOLD']);
37
53
  options.serverSelectionTimeoutMS =
38
- options.serverSelectionTimeoutMS ?? toInt(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
39
- options.minHeartbeatFrequencyMS = options.minHeartbeatFrequencyMS ?? toInt(env[prefix + 'HEARTBEAT_FREQUENCY']);
54
+ options.serverSelectionTimeoutMS ??
55
+ toInt(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
56
+ options.minHeartbeatFrequencyMS =
57
+ options.minHeartbeatFrequencyMS ??
58
+ toInt(env[prefix + 'HEARTBEAT_FREQUENCY']);
40
59
  options.appName = options.appName ?? env[prefix + 'APP_NAME'];
41
- options.retryReads = options.retryReads ?? toBoolean(env[prefix + 'RETRY_READS']);
42
- options.retryWrites = options.retryWrites ?? toBoolean(env[prefix + 'RETRY_WRITES']);
43
- options.directConnection = options.directConnection ?? toBoolean(env[prefix + 'DIRECT_CONNECTION']);
44
- options.loadBalanced = options.loadBalanced ?? toBoolean(env[prefix + 'LOAD_BALANCED']);
60
+ options.retryReads =
61
+ options.retryReads ?? toBoolean(env[prefix + 'RETRY_READS']);
62
+ options.retryWrites =
63
+ options.retryWrites ?? toBoolean(env[prefix + 'RETRY_WRITES']);
64
+ options.directConnection =
65
+ options.directConnection ?? toBoolean(env[prefix + 'DIRECT_CONNECTION']);
66
+ options.loadBalanced =
67
+ options.loadBalanced ?? toBoolean(env[prefix + 'LOAD_BALANCED']);
45
68
  options.noDelay = options.noDelay ?? toBoolean(env[prefix + 'NO_DELAY']);
46
- options.monitorCommands = options.monitorCommands ?? toBoolean(env[prefix + 'MONITOR_COMMANDS']);
69
+ options.monitorCommands =
70
+ options.monitorCommands ?? toBoolean(env[prefix + 'MONITOR_COMMANDS']);
47
71
  options.proxyHost = options.proxyHost ?? env[prefix + 'PROXY_HOST'];
48
72
  options.proxyPort = options.proxyPort ?? toInt(env[prefix + 'PROXY_PORT']);
49
73
  options.proxyUsername = options.proxyHost ?? env[prefix + 'PROXY_USERNAME'];
50
- options.proxyPassword = options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
74
+ options.proxyPassword =
75
+ options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
51
76
  return options;
52
77
  }
@@ -3,7 +3,7 @@ import { __decorate, __metadata, __param } from "tslib";
3
3
  import * as assert from 'node:assert';
4
4
  import * as crypto from 'node:crypto';
5
5
  import { omit } from '@jsopen/objects';
6
- import { Inject, Logger } from '@nestjs/common';
6
+ import { Inject, Logger, } from '@nestjs/common';
7
7
  import colors from 'ansi-colors';
8
8
  import { Db, MongoClient } from 'mongodb';
9
9
  import { MONGODB_CONNECTION_OPTIONS, MONGODB_MODULE_ID } from './constants.js';
@@ -52,7 +52,11 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
52
52
  provide: token,
53
53
  inject: [MONGODB_CONNECTION_OPTIONS],
54
54
  useFactory: async (connectionOptions) => {
55
- const mongoOptions = omit(connectionOptions, ['url', 'database', 'lazyConnect']);
55
+ const mongoOptions = omit(connectionOptions, [
56
+ 'url',
57
+ 'database',
58
+ 'lazyConnect',
59
+ ]);
56
60
  if (mongoOptions.auth && !mongoOptions.auth?.username)
57
61
  delete mongoOptions.auth;
58
62
  return new MongoClient(connectionOptions.url, mongoOptions);
@@ -62,7 +66,9 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
62
66
  provide: dbToken,
63
67
  inject: [token, MONGODB_CONNECTION_OPTIONS],
64
68
  useFactory: async (client, connectionOptions) => {
65
- return connectionOptions.database ? client.db(connectionOptions.database) : undefined;
69
+ return connectionOptions.database
70
+ ? client.db(connectionOptions.database)
71
+ : undefined;
66
72
  },
67
73
  },
68
74
  {
@@ -71,7 +77,9 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
71
77
  },
72
78
  {
73
79
  provide: Logger,
74
- useValue: typeof opts.logger === 'string' ? new Logger(opts.logger) : opts.logger,
80
+ useValue: typeof opts.logger === 'string'
81
+ ? new Logger(opts.logger)
82
+ : opts.logger,
75
83
  },
76
84
  ];
77
85
  return {
@@ -85,7 +93,12 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
85
93
  useValue: crypto.randomUUID(),
86
94
  },
87
95
  ],
88
- exports: [MONGODB_CONNECTION_OPTIONS, token, dbToken, ...(metadata.exports ?? [])],
96
+ exports: [
97
+ MONGODB_CONNECTION_OPTIONS,
98
+ token,
99
+ dbToken,
100
+ ...(metadata.exports ?? []),
101
+ ],
89
102
  };
90
103
  }
91
104
  /**
@@ -15,7 +15,8 @@ let MongodbHealthIndicator = class MongodbHealthIndicator {
15
15
  }
16
16
  async pingCheck(key, options) {
17
17
  const { HealthIndicatorService } = await import('@nestjs/terminus');
18
- this.healthIndicatorService = this.healthIndicatorService || new HealthIndicatorService();
18
+ this.healthIndicatorService =
19
+ this.healthIndicatorService || new HealthIndicatorService();
19
20
  const indicator = this.healthIndicatorService.check(key);
20
21
  let connection;
21
22
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xnestjs/mongodb",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "NestJS extension library for MongoDb",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "peerDependencies": {
14
14
  "@nestjs/common": "^10.0.0 || ^11.0.0",
15
15
  "@nestjs/core": "^10.0.0 || ^11.0.0",
16
- "mongodb": "^6.14.2"
16
+ "mongodb": "^6.15.0"
17
17
  },
18
18
  "type": "module",
19
19
  "exports": {