@xnestjs/mongodb 1.3.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/LICENSE +21 -0
- package/README.md +106 -0
- package/cjs/constants.js +5 -0
- package/cjs/index.js +6 -0
- package/cjs/mongodb-core.module.js +173 -0
- package/cjs/mongodb.module.js +32 -0
- package/cjs/package.json +3 -0
- package/cjs/types.js +2 -0
- package/esm/constants.js +2 -0
- package/esm/index.js +3 -0
- package/esm/mongodb-core.module.js +170 -0
- package/esm/mongodb.module.js +28 -0
- package/esm/package.json +3 -0
- package/esm/types.js +1 -0
- package/package.json +55 -0
- package/types/constants.d.ts +2 -0
- package/types/index.d.cts +3 -0
- package/types/index.d.ts +3 -0
- package/types/mongodb-core.module.d.ts +25 -0
- package/types/mongodb.module.d.ts +19 -0
- package/types/types.d.ts +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Panates
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# @xnestjs/mongodb
|
|
2
|
+
|
|
3
|
+
NestJS extension library for MongoDB
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @xnestjs/mongodb
|
|
9
|
+
# or using yarn
|
|
10
|
+
yarn add @xnestjs/mongodb
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Register sync
|
|
16
|
+
|
|
17
|
+
An example of nestjs module that import the @xnestjs/mongodb
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// module.ts
|
|
21
|
+
import { Module } from '@nestjs/common';
|
|
22
|
+
import { MongoModule } from '@xnestjs/mongodb';
|
|
23
|
+
|
|
24
|
+
@Module({
|
|
25
|
+
imports: [
|
|
26
|
+
MongodbModule.forRoot({
|
|
27
|
+
useValue: {
|
|
28
|
+
url: 'https://mydbserver:27017',
|
|
29
|
+
database: 'test',
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
})
|
|
34
|
+
export class MyModule {
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Register async
|
|
39
|
+
|
|
40
|
+
An example of nestjs module that import the @xnestjs/mongodb async
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
// module.ts
|
|
44
|
+
import { Module } from '@nestjs/common';
|
|
45
|
+
import { MongoModule } from '@xnestjs/mongodb';
|
|
46
|
+
|
|
47
|
+
@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
|
+
]
|
|
57
|
+
})
|
|
58
|
+
export class MyModule {
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Environment Variables
|
|
63
|
+
|
|
64
|
+
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.
|
|
66
|
+
|
|
67
|
+
| Environment Variable | Type | Default | Description |
|
|
68
|
+
|----------------------------------------|---------|---------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
69
|
+
| MONGODB_URL | String | mongodb://localhost:27017 | URL to MongoDB server |
|
|
70
|
+
| MONGODB_USERNAME | String | | The username for auth |
|
|
71
|
+
| MONGODB_PASSWORD | String | | The password for auth |
|
|
72
|
+
| MONGODB_AUTH_SOURCE | String | | Specify the database name associated with the user’s credentials. |
|
|
73
|
+
| MONGODB_DATABASE | String | | The database name |
|
|
74
|
+
| MONGODB_REPLICA_SET | String | | Specifies the name of the replica set, if the mongod is a member of a replica set. |
|
|
75
|
+
| MONGODB_TLS | Boolean | False | Enables or disables TLS/SSL for the connection. |
|
|
76
|
+
| MONGODB_TLS_CERT_FILE | String | | Specifies the location of a local .pem file that contains either the client's TLS/SSL certificate and key. |
|
|
77
|
+
| MONGODB_TLS_CERT_FILE_PASS | String | | Specifies the password to de-crypt the tlsCertificateKeyFile. |
|
|
78
|
+
| MONGODB_TLS_CA_FILE | String | | Specifies the location of a local .pem file that contains the root certificate chain from the Certificate Authority. This file is used to validate the certificate presented by the mongod/mongos instance. |
|
|
79
|
+
| MONGODB_TLS_CRL_FILE | String | | Specifies the location of a local CRL .pem file that contains the client revokation list. |
|
|
80
|
+
| MONGODB_TLS_ALLOW_INVALID_CERTIFICATES | Boolean | | Bypasses validation of the certificates presented by the mongod/mongos instance |
|
|
81
|
+
| MONGODB_TLS_ALLOW_INVALID_HOSTNAMES | Boolean | | Disables hostname validation of the certificate presented by the mongod/mongos instance. |
|
|
82
|
+
| MONGODB_TLS_INSECURE | Boolean | | Disables various certificate validations. |
|
|
83
|
+
| MONGODB_TIMEOUT | Number | | Specifies the time an operation will run until it throws a timeout error |
|
|
84
|
+
| MONGODB_CONNECT_TIMEOUT | Number | | The time in milliseconds to attempt a connection before timing out. |
|
|
85
|
+
| MONGODB_SOCKET_TIMEOUT | Number | | The time in milliseconds to attempt a send or receive on a socket before the attempt times out. |
|
|
86
|
+
| MONGODB_SRV_MAX_HOSTS | Number | | The maximum number of hosts to connect to when using an srv connection string, a setting of `0` means unlimited hosts |
|
|
87
|
+
| MONGODB_MAX_POOL_SIZE | Number | | The maximum number of connections in the connection pool |
|
|
88
|
+
| MONGODB_MIN_POOL_SIZE | Number | | The minimum number of connections in the connection pool. |
|
|
89
|
+
| MONGODB_MAX_CONNECTING | Number | | The maximum number of connections that may be in the process of being established concurrently by the connection pool. |
|
|
90
|
+
| MONGODB_MAX_IDLE_TIME | Number | | The maximum number of milliseconds that a connection can remain idle in the pool before being removed and closed. |
|
|
91
|
+
| MONGODB_MAX_WAIT_QUEUE_TIMEOUT | Number | | The maximum time in milliseconds that a thread can wait for a connection to become available. |
|
|
92
|
+
| MONGODB_MAX_STALENESS_SECONDS | Number | | Specifies, in seconds, how stale a secondary can be before the client stops using it for read operations. |
|
|
93
|
+
| MONGODB_LOCAL_THRESHOLD | Number | | The size (in milliseconds) of the latency window for selecting among multiple suitable MongoDB instances. |
|
|
94
|
+
| MONGODB_SERVER_SELECTION_TIMEOUT | Number | | Specifies how long (in milliseconds) to block for server selection before throwing an exception. |
|
|
95
|
+
| MONGODB_HEARTBEAT_FREQUENCY | Number | | heartbeatFrequencyMS controls when the driver checks the state of the MongoDB deployment. Specify the interval (in milliseconds) between checks, counted from the end of the previous check until the beginning of the next one. |
|
|
96
|
+
| MONGODB_APP_NAME | String | | The name of the application that created this MongoClient instance. MongoDB 3.4 and newer will print this value in the server log upon establishing each connection. It is also recorded in the slow query log and profile collections |
|
|
97
|
+
| MONGODB_RETRY_READS | Boolean | | Enables retryable reads. |
|
|
98
|
+
| MONGODB_RETRY_WRITES | Boolean | | Enable retryable writes. |
|
|
99
|
+
| MONGODB_DIRECT_CONNECTION | Boolean | | Allow a driver to force a Single topology type with a connection string containing one host |
|
|
100
|
+
| MONGODB_LOAD_BALANCED | Boolean | | Instruct the driver it is connecting to a load balancer fronting a mongos like service |
|
|
101
|
+
| MONGODB_NO_DELAY | Boolean | | TCP Connection no delay |
|
|
102
|
+
| MONGODB_MONITOR_COMMANDS | Boolean | | Enable command monitoring for this client |
|
|
103
|
+
| MONGODB_PROXY_HOST | String | | Configures a Socks5 proxy host used for creating TCP connections. |
|
|
104
|
+
| MONGODB_PROXY_PORT | String | | Configures a Socks5 proxy port used for creating TCP connections. |
|
|
105
|
+
| MONGODB_PROXY_USERNAME | String | | Configures a Socks5 proxy username when the proxy in proxyHost requires username/password authentication. |
|
|
106
|
+
| MONGODB_PROXY_PASSWORD | String | | Configures a Socks5 proxy password when the proxy in proxyHost requires username/password authentication. |
|
package/cjs/constants.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONGODB_MODULE_ID = exports.MONGODB_CONNECTION_OPTIONS = void 0;
|
|
4
|
+
exports.MONGODB_CONNECTION_OPTIONS = Symbol('MONGODB_CONNECTION_OPTIONS');
|
|
5
|
+
exports.MONGODB_MODULE_ID = Symbol('MONGODB_MODULE_ID');
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./constants.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./mongodb.module.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var MongodbCoreModule_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MongodbCoreModule = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const assert = tslib_1.__importStar(require("node:assert"));
|
|
7
|
+
const crypto = tslib_1.__importStar(require("node:crypto"));
|
|
8
|
+
const process = tslib_1.__importStar(require("node:process"));
|
|
9
|
+
const objects_1 = require("@jsopen/objects");
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const colors = tslib_1.__importStar(require("ansi-colors"));
|
|
12
|
+
const mongodb_1 = require("mongodb");
|
|
13
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
14
|
+
const constants_js_1 = require("./constants.js");
|
|
15
|
+
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
16
|
+
let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
|
|
17
|
+
/**
|
|
18
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
19
|
+
*/
|
|
20
|
+
static forRoot(moduleOptions) {
|
|
21
|
+
const connectionOptions = this._readConnectionOptions(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
22
|
+
return this._createDynamicModule(moduleOptions, {
|
|
23
|
+
global: moduleOptions.global,
|
|
24
|
+
providers: [
|
|
25
|
+
{
|
|
26
|
+
provide: constants_js_1.MONGODB_CONNECTION_OPTIONS,
|
|
27
|
+
useValue: connectionOptions,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
34
|
+
*/
|
|
35
|
+
static forRootAsync(asyncOptions) {
|
|
36
|
+
assert.ok(asyncOptions.useFactory, 'useFactory is required');
|
|
37
|
+
return this._createDynamicModule(asyncOptions, {
|
|
38
|
+
global: asyncOptions.global,
|
|
39
|
+
providers: [
|
|
40
|
+
{
|
|
41
|
+
provide: constants_js_1.MONGODB_CONNECTION_OPTIONS,
|
|
42
|
+
inject: asyncOptions.inject,
|
|
43
|
+
useFactory: async (...args) => {
|
|
44
|
+
const opts = await asyncOptions.useFactory(...args);
|
|
45
|
+
return this._readConnectionOptions(opts, asyncOptions.envPrefix);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
static _createDynamicModule(opts, metadata) {
|
|
52
|
+
const token = opts.token ?? mongodb_1.MongoClient;
|
|
53
|
+
const dbToken = opts.dbToken ?? mongodb_1.Db;
|
|
54
|
+
const providers = [
|
|
55
|
+
{
|
|
56
|
+
provide: token,
|
|
57
|
+
inject: [constants_js_1.MONGODB_CONNECTION_OPTIONS],
|
|
58
|
+
useFactory: async (connectionOptions) => {
|
|
59
|
+
const mongoOptions = (0, objects_1.omit)(connectionOptions, ['url', 'database', 'lazyConnect']);
|
|
60
|
+
if (mongoOptions.auth && !mongoOptions.auth?.username)
|
|
61
|
+
delete mongoOptions.auth;
|
|
62
|
+
return new mongodb_1.MongoClient(connectionOptions.url, mongoOptions);
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
provide: dbToken,
|
|
67
|
+
inject: [token, constants_js_1.MONGODB_CONNECTION_OPTIONS],
|
|
68
|
+
useFactory: async (client, connectionOptions) => {
|
|
69
|
+
return connectionOptions.database ? client.db(connectionOptions.database) : undefined;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
provide: CLIENT_TOKEN,
|
|
74
|
+
useExisting: token,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
provide: common_1.Logger,
|
|
78
|
+
useValue: typeof opts.logger === 'string' ? new common_1.Logger(opts.logger) : opts.logger,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
return {
|
|
82
|
+
module: MongodbCoreModule_1,
|
|
83
|
+
...metadata,
|
|
84
|
+
providers: [
|
|
85
|
+
...(metadata.providers ?? []),
|
|
86
|
+
...providers,
|
|
87
|
+
{
|
|
88
|
+
provide: constants_js_1.MONGODB_MODULE_ID,
|
|
89
|
+
useValue: crypto.randomUUID(),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
exports: [constants_js_1.MONGODB_CONNECTION_OPTIONS, token, dbToken, ...(metadata.exports ?? [])],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
static _readConnectionOptions(moduleOptions, prefix = 'MONGODB_') {
|
|
96
|
+
const options = (0, objects_1.clone)(moduleOptions);
|
|
97
|
+
const env = process.env;
|
|
98
|
+
options.url = options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
|
|
99
|
+
options.timeoutMS = options.timeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'TIMEOUT']);
|
|
100
|
+
options.replicaSet = options.replicaSet ?? env[prefix + 'REPLICA_SET'];
|
|
101
|
+
options.tls = options.tls ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS']);
|
|
102
|
+
options.tlsCertificateKeyFile = options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
|
|
103
|
+
options.tlsCertificateKeyFilePassword = options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
|
|
104
|
+
options.tlsCAFile = options.tlsCAFile ?? env[prefix + 'TLS_CA_FILE'];
|
|
105
|
+
options.tlsCRLFile = options.tlsCRLFile ?? env[prefix + 'TLS_CRL_FILE'];
|
|
106
|
+
options.tlsAllowInvalidCertificates =
|
|
107
|
+
options.tlsAllowInvalidCertificates ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
|
|
108
|
+
options.tlsAllowInvalidCertificates =
|
|
109
|
+
options.tlsAllowInvalidHostnames ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
|
|
110
|
+
options.tlsInsecure = options.tlsInsecure ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'TLS_INSECURE']);
|
|
111
|
+
options.connectTimeoutMS = options.connectTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'CONNECT_TIMEOUT']);
|
|
112
|
+
options.socketTimeoutMS = options.socketTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SOCKET_TIMEOUT']);
|
|
113
|
+
options.database = options.database ?? env[prefix + 'DATABASE'];
|
|
114
|
+
options.srvMaxHosts = options.srvMaxHosts ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SRV_MAX_HOSTS']);
|
|
115
|
+
options.maxPoolSize = options.minPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_POOL_SIZE']);
|
|
116
|
+
options.minPoolSize = options.maxPoolSize ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MIN_POOL_SIZE']);
|
|
117
|
+
options.maxConnecting = options.maxConnecting ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_CONNECTING']);
|
|
118
|
+
options.maxIdleTimeMS = options.maxIdleTimeMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_IDLE_TIME']);
|
|
119
|
+
options.waitQueueTimeoutMS = options.waitQueueTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
|
|
120
|
+
options.maxStalenessSeconds = options.maxStalenessSeconds ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'MAX_STALENESS_SECONDS']);
|
|
121
|
+
if (!options.auth?.username) {
|
|
122
|
+
options.auth = options.auth || {};
|
|
123
|
+
options.auth.username = options.auth.username ?? env[prefix + 'USERNAME'];
|
|
124
|
+
options.auth.password = options.auth.password ?? env[prefix + 'PASSWORD'];
|
|
125
|
+
}
|
|
126
|
+
options.authSource = options.authSource ?? env[prefix + 'AUTH_SOURCE'];
|
|
127
|
+
options.localThresholdMS = options.localThresholdMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'LOCAL_THRESHOLD']);
|
|
128
|
+
options.serverSelectionTimeoutMS =
|
|
129
|
+
options.serverSelectionTimeoutMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
|
|
130
|
+
options.minHeartbeatFrequencyMS = options.minHeartbeatFrequencyMS ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'HEARTBEAT_FREQUENCY']);
|
|
131
|
+
options.appName = options.appName ?? env[prefix + 'APP_NAME'];
|
|
132
|
+
options.retryReads = options.retryReads ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_READS']);
|
|
133
|
+
options.retryWrites = options.retryWrites ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'RETRY_WRITES']);
|
|
134
|
+
options.directConnection = options.directConnection ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'DIRECT_CONNECTION']);
|
|
135
|
+
options.loadBalanced = options.loadBalanced ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'LOAD_BALANCED']);
|
|
136
|
+
options.noDelay = options.noDelay ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'NO_DELAY']);
|
|
137
|
+
options.monitorCommands = options.monitorCommands ?? (0, putil_varhelpers_1.toBoolean)(env[prefix + 'MONITOR_COMMANDS']);
|
|
138
|
+
options.proxyHost = options.proxyHost ?? env[prefix + 'PROXY_HOST'];
|
|
139
|
+
options.proxyPort = options.proxyPort ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'PROXY_PORT']);
|
|
140
|
+
options.proxyUsername = options.proxyHost ?? env[prefix + 'PROXY_USERNAME'];
|
|
141
|
+
options.proxyPassword = options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
|
|
142
|
+
return options;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @constructor
|
|
147
|
+
*/
|
|
148
|
+
constructor(client, connectionOptions, logger) {
|
|
149
|
+
this.client = client;
|
|
150
|
+
this.connectionOptions = connectionOptions;
|
|
151
|
+
this.logger = logger;
|
|
152
|
+
}
|
|
153
|
+
onApplicationBootstrap() {
|
|
154
|
+
const options = this.connectionOptions;
|
|
155
|
+
if (!options.lazyConnect) {
|
|
156
|
+
this.logger?.log(`Connecting to MongoDB [${options.database}] at ${colors.blue(options.url)}`);
|
|
157
|
+
common_1.Logger.flush();
|
|
158
|
+
return this.client.connect().catch(e => {
|
|
159
|
+
this.logger?.error('MongoDB connection failed: ' + e.message);
|
|
160
|
+
throw e;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
onApplicationShutdown() {
|
|
165
|
+
return this.client.close(true);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
exports.MongodbCoreModule = MongodbCoreModule;
|
|
169
|
+
exports.MongodbCoreModule = MongodbCoreModule = MongodbCoreModule_1 = tslib_1.__decorate([
|
|
170
|
+
tslib_1.__param(0, (0, common_1.Inject)(CLIENT_TOKEN)),
|
|
171
|
+
tslib_1.__param(1, (0, common_1.Inject)(constants_js_1.MONGODB_CONNECTION_OPTIONS)),
|
|
172
|
+
tslib_1.__metadata("design:paramtypes", [mongodb_1.MongoClient, Object, common_1.Logger])
|
|
173
|
+
], MongodbCoreModule);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongodbModule = void 0;
|
|
4
|
+
const mongodb_core_module_js_1 = require("./mongodb-core.module.js");
|
|
5
|
+
/**
|
|
6
|
+
* The `MongodbCoreModule` class provides static methods to configure and
|
|
7
|
+
* return dynamic modules for MongoDB integration. This module facilitates
|
|
8
|
+
* the setup of MongoDB connections and connection options. It is designed
|
|
9
|
+
* to support both synchronous and asynchronous configuration approaches,
|
|
10
|
+
* making it flexible for various application setups.
|
|
11
|
+
*/
|
|
12
|
+
class MongodbModule {
|
|
13
|
+
/**
|
|
14
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
15
|
+
*/
|
|
16
|
+
static forRoot(options) {
|
|
17
|
+
return {
|
|
18
|
+
module: MongodbModule,
|
|
19
|
+
imports: [mongodb_core_module_js_1.MongodbCoreModule.forRoot(options || {})],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
24
|
+
*/
|
|
25
|
+
static forRootAsync(options) {
|
|
26
|
+
return {
|
|
27
|
+
module: MongodbModule,
|
|
28
|
+
imports: [mongodb_core_module_js_1.MongodbCoreModule.forRootAsync(options)],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.MongodbModule = MongodbModule;
|
package/cjs/package.json
ADDED
package/cjs/types.js
ADDED
package/esm/constants.js
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
var MongodbCoreModule_1;
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
+
import * as assert from 'node:assert';
|
|
4
|
+
import * as crypto from 'node:crypto';
|
|
5
|
+
import * as process from 'node:process';
|
|
6
|
+
import { clone, omit } from '@jsopen/objects';
|
|
7
|
+
import { Inject, Logger } from '@nestjs/common';
|
|
8
|
+
import * as colors from 'ansi-colors';
|
|
9
|
+
import { Db, MongoClient } from 'mongodb';
|
|
10
|
+
import { toBoolean, toInt } from 'putil-varhelpers';
|
|
11
|
+
import { MONGODB_CONNECTION_OPTIONS, MONGODB_MODULE_ID } from './constants.js';
|
|
12
|
+
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
13
|
+
let MongodbCoreModule = MongodbCoreModule_1 = class MongodbCoreModule {
|
|
14
|
+
/**
|
|
15
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
16
|
+
*/
|
|
17
|
+
static forRoot(moduleOptions) {
|
|
18
|
+
const connectionOptions = this._readConnectionOptions(moduleOptions.useValue || {}, moduleOptions.envPrefix);
|
|
19
|
+
return this._createDynamicModule(moduleOptions, {
|
|
20
|
+
global: moduleOptions.global,
|
|
21
|
+
providers: [
|
|
22
|
+
{
|
|
23
|
+
provide: MONGODB_CONNECTION_OPTIONS,
|
|
24
|
+
useValue: connectionOptions,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
31
|
+
*/
|
|
32
|
+
static forRootAsync(asyncOptions) {
|
|
33
|
+
assert.ok(asyncOptions.useFactory, 'useFactory is required');
|
|
34
|
+
return this._createDynamicModule(asyncOptions, {
|
|
35
|
+
global: asyncOptions.global,
|
|
36
|
+
providers: [
|
|
37
|
+
{
|
|
38
|
+
provide: MONGODB_CONNECTION_OPTIONS,
|
|
39
|
+
inject: asyncOptions.inject,
|
|
40
|
+
useFactory: async (...args) => {
|
|
41
|
+
const opts = await asyncOptions.useFactory(...args);
|
|
42
|
+
return this._readConnectionOptions(opts, asyncOptions.envPrefix);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
static _createDynamicModule(opts, metadata) {
|
|
49
|
+
const token = opts.token ?? MongoClient;
|
|
50
|
+
const dbToken = opts.dbToken ?? Db;
|
|
51
|
+
const providers = [
|
|
52
|
+
{
|
|
53
|
+
provide: token,
|
|
54
|
+
inject: [MONGODB_CONNECTION_OPTIONS],
|
|
55
|
+
useFactory: async (connectionOptions) => {
|
|
56
|
+
const mongoOptions = omit(connectionOptions, ['url', 'database', 'lazyConnect']);
|
|
57
|
+
if (mongoOptions.auth && !mongoOptions.auth?.username)
|
|
58
|
+
delete mongoOptions.auth;
|
|
59
|
+
return new MongoClient(connectionOptions.url, mongoOptions);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
provide: dbToken,
|
|
64
|
+
inject: [token, MONGODB_CONNECTION_OPTIONS],
|
|
65
|
+
useFactory: async (client, connectionOptions) => {
|
|
66
|
+
return connectionOptions.database ? client.db(connectionOptions.database) : undefined;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
provide: CLIENT_TOKEN,
|
|
71
|
+
useExisting: token,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
provide: Logger,
|
|
75
|
+
useValue: typeof opts.logger === 'string' ? new Logger(opts.logger) : opts.logger,
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
return {
|
|
79
|
+
module: MongodbCoreModule_1,
|
|
80
|
+
...metadata,
|
|
81
|
+
providers: [
|
|
82
|
+
...(metadata.providers ?? []),
|
|
83
|
+
...providers,
|
|
84
|
+
{
|
|
85
|
+
provide: MONGODB_MODULE_ID,
|
|
86
|
+
useValue: crypto.randomUUID(),
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
exports: [MONGODB_CONNECTION_OPTIONS, token, dbToken, ...(metadata.exports ?? [])],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static _readConnectionOptions(moduleOptions, prefix = 'MONGODB_') {
|
|
93
|
+
const options = clone(moduleOptions);
|
|
94
|
+
const env = process.env;
|
|
95
|
+
options.url = options.url || (env[prefix + 'URL'] ?? 'mongodb://localhost:27017');
|
|
96
|
+
options.timeoutMS = options.timeoutMS ?? toInt(env[prefix + 'TIMEOUT']);
|
|
97
|
+
options.replicaSet = options.replicaSet ?? env[prefix + 'REPLICA_SET'];
|
|
98
|
+
options.tls = options.tls ?? toBoolean(env[prefix + 'TLS']);
|
|
99
|
+
options.tlsCertificateKeyFile = options.tlsCertificateKeyFile ?? env[prefix + 'TLS_CERT_FILE'];
|
|
100
|
+
options.tlsCertificateKeyFilePassword = options.tlsCertificateKeyFilePassword ?? env[prefix + 'TLS_CERT_FILE_PASS'];
|
|
101
|
+
options.tlsCAFile = options.tlsCAFile ?? env[prefix + 'TLS_CA_FILE'];
|
|
102
|
+
options.tlsCRLFile = options.tlsCRLFile ?? env[prefix + 'TLS_CRL_FILE'];
|
|
103
|
+
options.tlsAllowInvalidCertificates =
|
|
104
|
+
options.tlsAllowInvalidCertificates ?? toBoolean(env[prefix + 'TLS_ALLOW_INVALID_CERTIFICATES']);
|
|
105
|
+
options.tlsAllowInvalidCertificates =
|
|
106
|
+
options.tlsAllowInvalidHostnames ?? toBoolean(env[prefix + 'TLS_ALLOW_INVALID_HOSTNAMES']);
|
|
107
|
+
options.tlsInsecure = options.tlsInsecure ?? toBoolean(env[prefix + 'TLS_INSECURE']);
|
|
108
|
+
options.connectTimeoutMS = options.connectTimeoutMS ?? toInt(env[prefix + 'CONNECT_TIMEOUT']);
|
|
109
|
+
options.socketTimeoutMS = options.socketTimeoutMS ?? toInt(env[prefix + 'SOCKET_TIMEOUT']);
|
|
110
|
+
options.database = options.database ?? env[prefix + 'DATABASE'];
|
|
111
|
+
options.srvMaxHosts = options.srvMaxHosts ?? toInt(env[prefix + 'SRV_MAX_HOSTS']);
|
|
112
|
+
options.maxPoolSize = options.minPoolSize ?? toInt(env[prefix + 'MAX_POOL_SIZE']);
|
|
113
|
+
options.minPoolSize = options.maxPoolSize ?? toInt(env[prefix + 'MIN_POOL_SIZE']);
|
|
114
|
+
options.maxConnecting = options.maxConnecting ?? toInt(env[prefix + 'MAX_CONNECTING']);
|
|
115
|
+
options.maxIdleTimeMS = options.maxIdleTimeMS ?? toInt(env[prefix + 'MAX_IDLE_TIME']);
|
|
116
|
+
options.waitQueueTimeoutMS = options.waitQueueTimeoutMS ?? toInt(env[prefix + 'MAX_WAIT_QUEUE_TIMEOUT']);
|
|
117
|
+
options.maxStalenessSeconds = options.maxStalenessSeconds ?? toInt(env[prefix + 'MAX_STALENESS_SECONDS']);
|
|
118
|
+
if (!options.auth?.username) {
|
|
119
|
+
options.auth = options.auth || {};
|
|
120
|
+
options.auth.username = options.auth.username ?? env[prefix + 'USERNAME'];
|
|
121
|
+
options.auth.password = options.auth.password ?? env[prefix + 'PASSWORD'];
|
|
122
|
+
}
|
|
123
|
+
options.authSource = options.authSource ?? env[prefix + 'AUTH_SOURCE'];
|
|
124
|
+
options.localThresholdMS = options.localThresholdMS ?? toInt(env[prefix + 'LOCAL_THRESHOLD']);
|
|
125
|
+
options.serverSelectionTimeoutMS =
|
|
126
|
+
options.serverSelectionTimeoutMS ?? toInt(env[prefix + 'SERVER_SELECTION_TIMEOUT']);
|
|
127
|
+
options.minHeartbeatFrequencyMS = options.minHeartbeatFrequencyMS ?? toInt(env[prefix + 'HEARTBEAT_FREQUENCY']);
|
|
128
|
+
options.appName = options.appName ?? env[prefix + 'APP_NAME'];
|
|
129
|
+
options.retryReads = options.retryReads ?? toBoolean(env[prefix + 'RETRY_READS']);
|
|
130
|
+
options.retryWrites = options.retryWrites ?? toBoolean(env[prefix + 'RETRY_WRITES']);
|
|
131
|
+
options.directConnection = options.directConnection ?? toBoolean(env[prefix + 'DIRECT_CONNECTION']);
|
|
132
|
+
options.loadBalanced = options.loadBalanced ?? toBoolean(env[prefix + 'LOAD_BALANCED']);
|
|
133
|
+
options.noDelay = options.noDelay ?? toBoolean(env[prefix + 'NO_DELAY']);
|
|
134
|
+
options.monitorCommands = options.monitorCommands ?? toBoolean(env[prefix + 'MONITOR_COMMANDS']);
|
|
135
|
+
options.proxyHost = options.proxyHost ?? env[prefix + 'PROXY_HOST'];
|
|
136
|
+
options.proxyPort = options.proxyPort ?? toInt(env[prefix + 'PROXY_PORT']);
|
|
137
|
+
options.proxyUsername = options.proxyHost ?? env[prefix + 'PROXY_USERNAME'];
|
|
138
|
+
options.proxyPassword = options.proxyPassword ?? env[prefix + 'PROXY_PASSWORD'];
|
|
139
|
+
return options;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @constructor
|
|
144
|
+
*/
|
|
145
|
+
constructor(client, connectionOptions, logger) {
|
|
146
|
+
this.client = client;
|
|
147
|
+
this.connectionOptions = connectionOptions;
|
|
148
|
+
this.logger = logger;
|
|
149
|
+
}
|
|
150
|
+
onApplicationBootstrap() {
|
|
151
|
+
const options = this.connectionOptions;
|
|
152
|
+
if (!options.lazyConnect) {
|
|
153
|
+
this.logger?.log(`Connecting to MongoDB [${options.database}] at ${colors.blue(options.url)}`);
|
|
154
|
+
Logger.flush();
|
|
155
|
+
return this.client.connect().catch(e => {
|
|
156
|
+
this.logger?.error('MongoDB connection failed: ' + e.message);
|
|
157
|
+
throw e;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
onApplicationShutdown() {
|
|
162
|
+
return this.client.close(true);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
MongodbCoreModule = MongodbCoreModule_1 = __decorate([
|
|
166
|
+
__param(0, Inject(CLIENT_TOKEN)),
|
|
167
|
+
__param(1, Inject(MONGODB_CONNECTION_OPTIONS)),
|
|
168
|
+
__metadata("design:paramtypes", [MongoClient, Object, Logger])
|
|
169
|
+
], MongodbCoreModule);
|
|
170
|
+
export { MongodbCoreModule };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MongodbCoreModule } from './mongodb-core.module.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `MongodbCoreModule` class provides static methods to configure and
|
|
4
|
+
* return dynamic modules for MongoDB integration. This module facilitates
|
|
5
|
+
* the setup of MongoDB connections and connection options. It is designed
|
|
6
|
+
* to support both synchronous and asynchronous configuration approaches,
|
|
7
|
+
* making it flexible for various application setups.
|
|
8
|
+
*/
|
|
9
|
+
export class MongodbModule {
|
|
10
|
+
/**
|
|
11
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
12
|
+
*/
|
|
13
|
+
static forRoot(options) {
|
|
14
|
+
return {
|
|
15
|
+
module: MongodbModule,
|
|
16
|
+
imports: [MongodbCoreModule.forRoot(options || {})],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
21
|
+
*/
|
|
22
|
+
static forRootAsync(options) {
|
|
23
|
+
return {
|
|
24
|
+
module: MongodbModule,
|
|
25
|
+
imports: [MongodbCoreModule.forRootAsync(options)],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
package/esm/package.json
ADDED
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xnestjs/mongodb",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "NestJS extension library for MongoDb",
|
|
5
|
+
"author": "Panates",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@jsopen/objects": "^1.5.2",
|
|
9
|
+
"ansi-colors": "^4.1.3",
|
|
10
|
+
"putil-varhelpers": "^1.6.5",
|
|
11
|
+
"tslib": "^2.8.1"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
15
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
16
|
+
"mongodb": "^6.13.1"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./types/index.d.ts",
|
|
23
|
+
"default": "./esm/index.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./types/index.d.cts",
|
|
27
|
+
"default": "./cjs/index.js"
|
|
28
|
+
},
|
|
29
|
+
"default": "./esm/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"main": "./cjs/index.js",
|
|
34
|
+
"module": "./esm/index.js",
|
|
35
|
+
"types": "./types/index.d.ts",
|
|
36
|
+
"repository": {
|
|
37
|
+
"registry": "https://github.com/panates/xnestjs.git",
|
|
38
|
+
"directory": "packages/mongodb"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=16.0",
|
|
42
|
+
"npm": ">=7.0.0"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"cjs/",
|
|
46
|
+
"esm/",
|
|
47
|
+
"types/",
|
|
48
|
+
"LICENSE",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"keywords": [
|
|
52
|
+
"nestjs",
|
|
53
|
+
"mongodb"
|
|
54
|
+
]
|
|
55
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DynamicModule, Logger, OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
|
|
2
|
+
import { MongoClient } from 'mongodb';
|
|
3
|
+
import type { MongodbConnectionOptions, MongodbModuleAsyncOptions, MongodbModuleOptions } from './types.js';
|
|
4
|
+
export declare class MongodbCoreModule implements OnApplicationShutdown, OnApplicationBootstrap {
|
|
5
|
+
protected client: MongoClient;
|
|
6
|
+
private connectionOptions;
|
|
7
|
+
private logger?;
|
|
8
|
+
/**
|
|
9
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
10
|
+
*/
|
|
11
|
+
static forRoot(moduleOptions: MongodbModuleOptions): DynamicModule;
|
|
12
|
+
/**
|
|
13
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
14
|
+
*/
|
|
15
|
+
static forRootAsync(asyncOptions: MongodbModuleAsyncOptions): DynamicModule;
|
|
16
|
+
private static _createDynamicModule;
|
|
17
|
+
private static _readConnectionOptions;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @constructor
|
|
21
|
+
*/
|
|
22
|
+
constructor(client: MongoClient, connectionOptions: MongodbConnectionOptions, logger?: Logger | undefined);
|
|
23
|
+
onApplicationBootstrap(): Promise<MongoClient> | undefined;
|
|
24
|
+
onApplicationShutdown(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { MongodbModuleAsyncOptions, MongodbModuleOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `MongodbCoreModule` class provides static methods to configure and
|
|
5
|
+
* return dynamic modules for MongoDB integration. This module facilitates
|
|
6
|
+
* the setup of MongoDB connections and connection options. It is designed
|
|
7
|
+
* to support both synchronous and asynchronous configuration approaches,
|
|
8
|
+
* making it flexible for various application setups.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MongodbModule {
|
|
11
|
+
/**
|
|
12
|
+
* Configures and returns a dynamic module for MongoDB integration.
|
|
13
|
+
*/
|
|
14
|
+
static forRoot(options?: MongodbModuleOptions): DynamicModule;
|
|
15
|
+
/**
|
|
16
|
+
* Configures and returns an async dynamic module for MongoDB integration.
|
|
17
|
+
*/
|
|
18
|
+
static forRootAsync(options: MongodbModuleAsyncOptions): DynamicModule;
|
|
19
|
+
}
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Logger } from '@nestjs/common';
|
|
2
|
+
import type { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
3
|
+
import type { InjectionToken } from '@nestjs/common/interfaces/modules/injection-token.interface';
|
|
4
|
+
import type { MongoClientOptions } from 'mongodb';
|
|
5
|
+
export interface MongodbConnectionOptions extends MongoClientOptions {
|
|
6
|
+
url?: string;
|
|
7
|
+
database?: string;
|
|
8
|
+
lazyConnect?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface BaseModuleOptions {
|
|
11
|
+
token?: InjectionToken;
|
|
12
|
+
dbToken?: InjectionToken;
|
|
13
|
+
envPrefix?: string;
|
|
14
|
+
logger?: Logger | string;
|
|
15
|
+
global?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface MongodbModuleOptions extends BaseModuleOptions {
|
|
18
|
+
useValue?: MongodbConnectionOptions;
|
|
19
|
+
}
|
|
20
|
+
export interface MongodbModuleAsyncOptions extends BaseModuleOptions, Pick<ModuleMetadata, 'imports'> {
|
|
21
|
+
inject?: InjectionToken[];
|
|
22
|
+
useFactory: (...args: any[]) => Promise<MongodbConnectionOptions> | MongodbConnectionOptions;
|
|
23
|
+
}
|
|
24
|
+
export {};
|