@xnestjs/mongodb 1.13.0 → 1.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.
@@ -19,6 +19,6 @@ export declare class MongodbCoreModule implements OnApplicationShutdown, OnAppli
19
19
  * @constructor
20
20
  */
21
21
  constructor(client: MongoClient, connectionOptions: MongodbConnectionOptions, logger?: Logger | undefined);
22
- onApplicationBootstrap(): Promise<MongoClient> | undefined;
22
+ onApplicationBootstrap(): Promise<void> | undefined;
23
23
  onApplicationShutdown(): Promise<void>;
24
24
  }
@@ -110,16 +110,26 @@ let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
110
110
  this.client = client;
111
111
  this.connectionOptions = connectionOptions;
112
112
  this.logger = logger;
113
+ this.logger = logger || new Logger('MongoDB');
113
114
  }
114
115
  onApplicationBootstrap() {
115
116
  const options = this.connectionOptions;
116
117
  if (options.lazyConnect)
117
118
  return;
118
- this.logger?.log(`Connecting to MongoDB [${options.database}] at ${colors.blue(options.url)}`);
119
119
  Logger.flush();
120
- return this.client.connect().catch(e => {
120
+ const logTimer = setTimeout(() => {
121
+ this.logger?.verbose(`Waiting to connect to MongoDB [${colors.blue(options.url)}]`);
122
+ }, 1000);
123
+ return this.client
124
+ .connect()
125
+ .catch(e => {
126
+ clearTimeout(logTimer);
121
127
  this.logger?.error('MongoDB connection failed: ' + e.message);
122
128
  throw e;
129
+ })
130
+ .then(() => {
131
+ clearTimeout(logTimer);
132
+ this.logger?.log(`MongoDB connection established`);
123
133
  });
124
134
  }
125
135
  onApplicationShutdown() {
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@xnestjs/mongodb",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
4
4
  "description": "NestJS extension library for MongoDb",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
- "@jsopen/objects": "^2.0.2",
8
+ "@jsopen/objects": "^2.1.0",
9
9
  "ansi-colors": "^4.1.3",
10
- "putil-varhelpers": "^1.6.5",
10
+ "putil-varhelpers": "^1.7.0",
11
11
  "tslib": "^2.8.1"
12
12
  },
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": "^7.0.0"
16
+ "mongodb": "^7.1.0"
17
17
  },
18
18
  "type": "module",
19
19
  "module": "./index.js",