@edirect/mongo 11.0.48 → 11.0.49

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
@@ -23,13 +23,13 @@ npm install @edirect/mongo
23
23
 
24
24
  ### Environment Variables
25
25
 
26
- | Variable | Type | Default | Description |
27
- |----------|------|---------|-------------|
28
- | `MONGO_URL` | `string` | — | Primary MongoDB connection string (takes precedence over `MONGODB_URI`). |
29
- | `MONGODB_URI` | `string` | — | Fallback MongoDB connection string. |
30
- | `NODE_ENV` | `string` | — | Runtime environment. When `production` or `live`, pool tuning is disabled. |
31
- | `MONGODB_AWS_ROLE_ARN` | `string` | — | **AWS IAM auth only.** ARN of the IAM role to assume via STS. |
32
- | `AWS_WEB_IDENTITY_TOKEN_FILE` | `string` | — | **AWS IAM auth only.** Path to the Kubernetes service-account token file for IRSA. |
26
+ | Variable | Type | Default | Description |
27
+ | ----------------------------- | -------- | ------- | ---------------------------------------------------------------------------------- |
28
+ | `MONGO_URL` | `string` | — | Primary MongoDB connection string (takes precedence over `MONGODB_URI`). |
29
+ | `MONGODB_URI` | `string` | — | Fallback MongoDB connection string. |
30
+ | `NODE_ENV` | `string` | — | Runtime environment. When `production` or `live`, pool tuning is disabled. |
31
+ | `MONGODB_AWS_ROLE_ARN` | `string` | — | **AWS IAM auth only.** ARN of the IAM role to assume via STS. |
32
+ | `AWS_WEB_IDENTITY_TOKEN_FILE` | `string` | — | **AWS IAM auth only.** Path to the Kubernetes service-account token file for IRSA. |
33
33
 
34
34
  > At least one of `MONGO_URL` or `MONGODB_URI` must be set, or the module will throw at startup.
35
35
 
@@ -60,7 +60,7 @@ import mongoose from 'mongoose';
60
60
  @Injectable()
61
61
  export class DatabaseService {
62
62
  constructor(
63
- @Inject(MONGO_CONNECTION) private readonly connection: mongoose.Mongoose,
63
+ @Inject(MONGO_CONNECTION) private readonly connection: mongoose.Mongoose
64
64
  ) {}
65
65
 
66
66
  isConnected(): boolean {
@@ -122,17 +122,20 @@ const config = new ConfigService();
122
122
  const connectionParams = getConnection(config);
123
123
  // Returns mongoose connection parameters object
124
124
 
125
- const connection = await mongoose.createConnection(connectionParams.uri, connectionParams.options);
125
+ const connection = await mongoose.createConnection(
126
+ connectionParams.uri,
127
+ connectionParams.options
128
+ );
126
129
  ```
127
130
 
128
131
  ### Connection Pool Sizing
129
132
 
130
133
  The module automatically adjusts pool settings based on `NODE_ENV`:
131
134
 
132
- | `NODE_ENV` | Behavior |
133
- |-----------|----------|
134
- | `production` / `live` | Default Mongoose pool settings |
135
- | anything else | Conservative pool settings (reduced for development) |
135
+ | `NODE_ENV` | Behavior |
136
+ | --------------------- | ---------------------------------------------------- |
137
+ | `production` / `live` | Default Mongoose pool settings |
138
+ | anything else | Conservative pool settings (reduced for development) |
136
139
 
137
140
  ## API Reference
138
141
 
@@ -148,8 +151,8 @@ import { MongoModule } from '@edirect/mongo';
148
151
 
149
152
  Utility function that resolves the MongoDB connection string from `ConfigService` and returns the connection parameters.
150
153
 
151
- | Parameter | Type | Description |
152
- |-----------|------|-------------|
154
+ | Parameter | Type | Description |
155
+ | --------------- | --------------- | ----------------------------------------------- |
153
156
  | `configService` | `ConfigService` | Instance of `@edirect/config`'s `ConfigService` |
154
157
 
155
158
  **Returns:** Object containing the resolved URI and Mongoose connection options.
@@ -197,7 +200,8 @@ const PolicySchema = new Schema({
197
200
  providers: [
198
201
  {
199
202
  provide: 'POLICY_MODEL',
200
- useFactory: (conn: mongoose.Mongoose) => conn.model('Policy', PolicySchema),
203
+ useFactory: (conn: mongoose.Mongoose) =>
204
+ conn.model('Policy', PolicySchema),
201
205
  inject: [MONGO_CONNECTION],
202
206
  },
203
207
  PolicyService,
@@ -215,7 +219,7 @@ import { Model } from 'mongoose';
215
219
  @Injectable()
216
220
  export class PolicyService {
217
221
  constructor(
218
- @Inject('POLICY_MODEL') private readonly policyModel: Model<any>,
222
+ @Inject('POLICY_MODEL') private readonly policyModel: Model<any>
219
223
  ) {}
220
224
 
221
225
  findAll() {
@@ -234,7 +238,7 @@ import mongoose from 'mongoose';
234
238
  @Injectable()
235
239
  export class HealthService {
236
240
  constructor(
237
- @Inject(MONGO_CONNECTION) private readonly mongo: mongoose.Mongoose,
241
+ @Inject(MONGO_CONNECTION) private readonly mongo: mongoose.Mongoose
238
242
  ) {}
239
243
 
240
244
  isHealthy(): boolean {
package/dist/README.md CHANGED
@@ -23,13 +23,13 @@ npm install @edirect/mongo
23
23
 
24
24
  ### Environment Variables
25
25
 
26
- | Variable | Type | Default | Description |
27
- |----------|------|---------|-------------|
28
- | `MONGO_URL` | `string` | — | Primary MongoDB connection string (takes precedence over `MONGODB_URI`). |
29
- | `MONGODB_URI` | `string` | — | Fallback MongoDB connection string. |
30
- | `NODE_ENV` | `string` | — | Runtime environment. When `production` or `live`, pool tuning is disabled. |
31
- | `MONGODB_AWS_ROLE_ARN` | `string` | — | **AWS IAM auth only.** ARN of the IAM role to assume via STS. |
32
- | `AWS_WEB_IDENTITY_TOKEN_FILE` | `string` | — | **AWS IAM auth only.** Path to the Kubernetes service-account token file for IRSA. |
26
+ | Variable | Type | Default | Description |
27
+ | ----------------------------- | -------- | ------- | ---------------------------------------------------------------------------------- |
28
+ | `MONGO_URL` | `string` | — | Primary MongoDB connection string (takes precedence over `MONGODB_URI`). |
29
+ | `MONGODB_URI` | `string` | — | Fallback MongoDB connection string. |
30
+ | `NODE_ENV` | `string` | — | Runtime environment. When `production` or `live`, pool tuning is disabled. |
31
+ | `MONGODB_AWS_ROLE_ARN` | `string` | — | **AWS IAM auth only.** ARN of the IAM role to assume via STS. |
32
+ | `AWS_WEB_IDENTITY_TOKEN_FILE` | `string` | — | **AWS IAM auth only.** Path to the Kubernetes service-account token file for IRSA. |
33
33
 
34
34
  > At least one of `MONGO_URL` or `MONGODB_URI` must be set, or the module will throw at startup.
35
35
 
@@ -60,7 +60,7 @@ import mongoose from 'mongoose';
60
60
  @Injectable()
61
61
  export class DatabaseService {
62
62
  constructor(
63
- @Inject(MONGO_CONNECTION) private readonly connection: mongoose.Mongoose,
63
+ @Inject(MONGO_CONNECTION) private readonly connection: mongoose.Mongoose
64
64
  ) {}
65
65
 
66
66
  isConnected(): boolean {
@@ -122,17 +122,20 @@ const config = new ConfigService();
122
122
  const connectionParams = getConnection(config);
123
123
  // Returns mongoose connection parameters object
124
124
 
125
- const connection = await mongoose.createConnection(connectionParams.uri, connectionParams.options);
125
+ const connection = await mongoose.createConnection(
126
+ connectionParams.uri,
127
+ connectionParams.options
128
+ );
126
129
  ```
127
130
 
128
131
  ### Connection Pool Sizing
129
132
 
130
133
  The module automatically adjusts pool settings based on `NODE_ENV`:
131
134
 
132
- | `NODE_ENV` | Behavior |
133
- |-----------|----------|
134
- | `production` / `live` | Default Mongoose pool settings |
135
- | anything else | Conservative pool settings (reduced for development) |
135
+ | `NODE_ENV` | Behavior |
136
+ | --------------------- | ---------------------------------------------------- |
137
+ | `production` / `live` | Default Mongoose pool settings |
138
+ | anything else | Conservative pool settings (reduced for development) |
136
139
 
137
140
  ## API Reference
138
141
 
@@ -148,8 +151,8 @@ import { MongoModule } from '@edirect/mongo';
148
151
 
149
152
  Utility function that resolves the MongoDB connection string from `ConfigService` and returns the connection parameters.
150
153
 
151
- | Parameter | Type | Description |
152
- |-----------|------|-------------|
154
+ | Parameter | Type | Description |
155
+ | --------------- | --------------- | ----------------------------------------------- |
153
156
  | `configService` | `ConfigService` | Instance of `@edirect/config`'s `ConfigService` |
154
157
 
155
158
  **Returns:** Object containing the resolved URI and Mongoose connection options.
@@ -197,7 +200,8 @@ const PolicySchema = new Schema({
197
200
  providers: [
198
201
  {
199
202
  provide: 'POLICY_MODEL',
200
- useFactory: (conn: mongoose.Mongoose) => conn.model('Policy', PolicySchema),
203
+ useFactory: (conn: mongoose.Mongoose) =>
204
+ conn.model('Policy', PolicySchema),
201
205
  inject: [MONGO_CONNECTION],
202
206
  },
203
207
  PolicyService,
@@ -215,7 +219,7 @@ import { Model } from 'mongoose';
215
219
  @Injectable()
216
220
  export class PolicyService {
217
221
  constructor(
218
- @Inject('POLICY_MODEL') private readonly policyModel: Model<any>,
222
+ @Inject('POLICY_MODEL') private readonly policyModel: Model<any>
219
223
  ) {}
220
224
 
221
225
  findAll() {
@@ -234,7 +238,7 @@ import mongoose from 'mongoose';
234
238
  @Injectable()
235
239
  export class HealthService {
236
240
  constructor(
237
- @Inject(MONGO_CONNECTION) private readonly mongo: mongoose.Mongoose,
241
+ @Inject(MONGO_CONNECTION) private readonly mongo: mongoose.Mongoose
238
242
  ) {}
239
243
 
240
244
  isHealthy(): boolean {
package/dist/package.json CHANGED
@@ -16,12 +16,11 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@aws-sdk/credential-providers": "^3.1001.0",
19
+ "@aws-sdk/credential-providers": "^3.1006.0",
20
20
  "@edirect/config": "^11.0.48",
21
- "@nestjs/common": "^11.1.15",
22
- "aws4": "^1.13.2",
21
+ "@nestjs/common": "^11.1.16",
23
22
  "mongodb": "^7.1.0",
24
- "mongoose": "^9.2.4",
23
+ "mongoose": "^9.3.0",
25
24
  "tslib": "^2.8.1"
26
25
  },
27
26
  "type": "commonjs"
@@ -1 +1 @@
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
+ {"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,EAAsB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASpE,wBAAsB,aAAa,CAAC,aAAa,EAAE,aAAa;;;GAmB/D;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,EAcpC,CAAC"}
@@ -10,7 +10,7 @@ const mongoUrl = (configService) => configService.get('MONGO_URL') ?? configServ
10
10
  async function getConnection(configService) {
11
11
  const connectionString = mongoUrl(configService);
12
12
  if (!connectionString)
13
- throw new Error('MongoDB connection string is not defined');
13
+ throw new config_1.ConfigMissingError('MONGO_URL');
14
14
  const options = {};
15
15
  // Always use dynamic AWS credential provider for MongoDB-AWS mechanism
16
16
  if ((connectionString ?? '').includes('MONGODB-AWS')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/mongo",
3
- "version": "11.0.48",
3
+ "version": "11.0.49",
4
4
  "packageScope": "@edirect",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -17,13 +17,12 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@aws-sdk/credential-providers": "^3.1001.0",
21
- "@nestjs/common": "^11.1.15",
22
- "aws4": "^1.13.2",
20
+ "@aws-sdk/credential-providers": "^3.1006.0",
21
+ "@nestjs/common": "^11.1.16",
23
22
  "mongodb": "^7.1.0",
24
- "mongoose": "^9.2.4",
23
+ "mongoose": "^9.3.0",
25
24
  "tslib": "^2.8.1",
26
- "@edirect/config": "11.0.48"
25
+ "@edirect/config": "11.0.49"
27
26
  },
28
27
  "nx": {
29
28
  "name": "@edirect/mongo",