@discue/mongodb-resource-client
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -74,3 +74,2 @@ const ResourceStorage = require('./simple-resource-storage.js') | ||
_registerEventHandlers(eventEmitter) { | ||
console.log(this._usageEventPrefix) | ||
eventEmitter.on(`${this._usageEventPrefix}.create`, (event) => this._eventHandler('create', event)) | ||
@@ -89,3 +88,2 @@ eventEmitter.on(`${this._usageEventPrefix}.update`, (event) => this._eventHandler('update', event)) | ||
async _eventHandler(action, { error, after, resourceIds }) { | ||
console.log('handler', action, after) | ||
if (!error) { | ||
@@ -92,0 +90,0 @@ if (action === 'create') { |
@@ -11,6 +11,3 @@ export type SimpleResourceStorage = import('./simple-resource-storage.js'); | ||
export const ResourceStorageHistory: typeof import("./history.js"); | ||
export type MongoResourceClient = { | ||
OneToFewRefStorage: import('./one-to-few-ref-storage.js'); | ||
OneToFewResourceStorage: import('./one-to-few-resource-storage.js'); | ||
OneToManyResourceStorage: import('./one-to-many-resource-storage.js'); | ||
}; | ||
export type ResourceLock = import('./locks.js'); | ||
export const ResourceLock: typeof import("./locks.js"); |
'use strict' | ||
/** | ||
* @typedef {Object} MongoResourceClient | ||
* | ||
* @property {import('./one-to-few-ref-storage.js')} OneToFewRefStorage | ||
* @property {import('./one-to-few-resource-storage.js')} OneToFewResourceStorage | ||
* @property {import('./one-to-many-resource-storage.js')} OneToManyResourceStorage | ||
*/ | ||
/** | ||
* @typedef {import('./simple-resource-storage.js')} SimpleResourceStorage | ||
@@ -34,2 +26,7 @@ */ | ||
*/ | ||
module.exports.ResourceStorageHistory = require('./history.js') | ||
module.exports.ResourceStorageHistory = require('./history.js') | ||
/** | ||
* @typedef {import('./locks.js')} ResourceLock | ||
*/ | ||
module.exports.ResourceLock = require('./locks.js') |
@@ -7,4 +7,4 @@ export = exports; | ||
*/ | ||
constructor(options: any); | ||
_resourceName: any; | ||
constructor(options: ConstructorOptions); | ||
_resourceName: string; | ||
/** | ||
@@ -52,3 +52,24 @@ * Returns all references. | ||
type ObjectId = import('mongodb').ObjectId; | ||
type ConstructorOptions = any; | ||
type ConstructorOptions = { | ||
/** | ||
* url to mongo instance. Can be null if client is set | ||
*/ | ||
url?: string; | ||
/** | ||
* configured mongo client to use. Can be null if url is set | ||
*/ | ||
client?: MongoClient; | ||
/** | ||
* name of the mongodb database | ||
*/ | ||
databaseName?: string; | ||
/** | ||
* name of the mongodb collection used to store the resources | ||
*/ | ||
collectionName: string; | ||
/** | ||
* name of the resource e.g. users, customers, topics, shipments | ||
*/ | ||
resourceName: string; | ||
}; | ||
type MongoClient = import('mongodb').MongoClient; |
@@ -7,3 +7,2 @@ const { EQUALS_ANY_OF, EQUALS } = require('./aggregations.js') | ||
* @typedef ConstructorOptions | ||
* @description Options for class constructor | ||
* @property {String} [url=null] url to mongo instance. Can be null if client is set | ||
@@ -10,0 +9,0 @@ * @property {MongoClient} [client=null] configured mongo client to use. Can be null if url is set |
@@ -7,4 +7,4 @@ export = exports; | ||
*/ | ||
constructor(options: any); | ||
_resourceName: any; | ||
constructor(options: ConstructorOptions); | ||
_resourceName: string; | ||
_emitUsageEvent: ({ context, resourceIds, before, after }: { | ||
@@ -79,3 +79,28 @@ context: any; | ||
import { Timestamp } from "mongodb"; | ||
type ConstructorOptions = any; | ||
type ConstructorOptions = { | ||
/** | ||
* url to mongo instance. Can be null if client is set | ||
*/ | ||
url?: string; | ||
/** | ||
* configured mongo client to use. Can be null if url is set | ||
*/ | ||
client?: MongoClient; | ||
/** | ||
* name of the mongodb database | ||
*/ | ||
databaseName?: string; | ||
/** | ||
* name of the mongodb collection used to store the resources | ||
*/ | ||
collectionName: string; | ||
/** | ||
* name of the resource e.g. users, customers, topics, shipments | ||
*/ | ||
resourceName: string; | ||
/** | ||
* if provided, will trigger events base on resource creation, updates and deletion | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
}; | ||
type MongoClient = import('mongodb').MongoClient; |
@@ -9,3 +9,2 @@ const { PROJECT, EQUALS } = require('./aggregations.js') | ||
* @typedef ConstructorOptions | ||
* @description Options for class constructor | ||
* @property {String} [url=null] url to mongo instance. Can be null if client is set | ||
@@ -12,0 +11,0 @@ * @property {MongoClient} [client=null] configured mongo client to use. Can be null if url is set |
@@ -8,7 +8,7 @@ export = exports; | ||
*/ | ||
constructor({ url, client, databaseName, collectionName, connectTimeout, eventEmitter }?: any); | ||
_mongoDbClient: any; | ||
_url: any; | ||
_databaseName: any; | ||
_collectionName: any; | ||
constructor({ url, client, databaseName, collectionName, connectTimeout, eventEmitter }?: ConstructorOptions); | ||
_mongoDbClient: MongoClient; | ||
_url: string; | ||
_databaseName: string; | ||
_collectionName: string; | ||
_emitUsageEventEnabled: boolean; | ||
@@ -147,2 +147,3 @@ _emiteUsageEvent: ({ context, resourceIds, before, after }: { | ||
} | ||
import { MongoClient } from "mongodb"; | ||
type Collection = import('mongodb').Collection; | ||
@@ -160,3 +161,28 @@ type GetOptions = { | ||
import { Timestamp } from "mongodb"; | ||
type ConstructorOptions = any; | ||
type ConstructorOptions = { | ||
/** | ||
* url to mongo instance. Can be null if client is set | ||
*/ | ||
url?: string; | ||
/** | ||
* configured mongo client to use. Can be null if url is set | ||
*/ | ||
client?: MongoClient; | ||
/** | ||
* name of the mongodb database | ||
*/ | ||
databaseName?: string; | ||
/** | ||
* name of the mongodb collection used to store the resources | ||
*/ | ||
collectionName: string; | ||
/** | ||
* the connect timeout of the mongo db client if client was not passed | ||
*/ | ||
connectTimeout?: number; | ||
/** | ||
* if provided, will trigger events base on resource creation, updates and deletion | ||
*/ | ||
eventEmitter: import('node:events').EventEmitter; | ||
}; | ||
type MongoClient = import('mongodb').MongoClient; |
@@ -8,3 +8,2 @@ const { MongoClient, Timestamp } = require('mongodb') | ||
* @typedef ConstructorOptions | ||
* @description Options for class constructor | ||
* @property {String} [url=null] url to mongo instance. Can be null if client is set | ||
@@ -64,3 +63,3 @@ * @property {MongoClient} [client=null] configured mongo client to use. Can be null if url is set | ||
this._url = url | ||
this._databaseName = process.env.MONGODB_RESOURCE_CLIENT_DB_NAME || databaseName | ||
this._databaseName = process.env.DSQ_MONGOD_RESOURCE_CLIENT_DB_NAME || databaseName | ||
this._collectionName = collectionName | ||
@@ -67,0 +66,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Simple wrapper around mongodb client allowing easier managing of resources", | ||
@@ -19,5 +19,2 @@ "main": "lib/index", | ||
"*": { | ||
".": [ | ||
"lib/index.d.ts" | ||
], | ||
"aggregations": [ | ||
@@ -64,10 +61,8 @@ "lib/aggregations.d.ts" | ||
"standard-version": "^9.5.0", | ||
"typescript": "^5.1.6" | ||
"typescript": "^5.1.6", | ||
"@types/node": "^20.4.10" | ||
}, | ||
"optionalDependencies": { | ||
"mongodb": "^5.7.0" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^20.4.10" | ||
} | ||
} |
@@ -31,3 +31,4 @@ | ||
- [OneToManyResourceStorage](README_ONE_TO_MANY_RESOURCE_STORAGE.md) | ||
- [StorageHistory](README_STORAGE_HISTORY.md) | ||
- [ResourceStorageHistory](README_STORAGE_HISTORY.md) | ||
- [ResourceLock](README_STORAGE_LOCK.md) | ||
- [SimpleResourceStorage](README_SIMPLE_RESOURCE_STORAGE.md) | ||
@@ -65,5 +66,7 @@ | ||
## Locks | ||
The module supports creating locks. Meaning: A way to synchronize application functionality e.g. for rate limiting. Check out the [ResourceLock](README_STORAGE_LOCK.md) documentation to find out more. | ||
## Database name | ||
The database name can be configured via environment variable: `MONGODB_RESOURCE_CLIENT_DB_NAME` | ||
The database name can be configured via environment variable: `DSQ_MONGOD_RESOURCE_CLIENT_DB_NAME` | ||
@@ -70,0 +73,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
93593
1
24
2325
88
9
+ Added@types/node@22.9.0(transitive)
- Removed@types/node@^20.4.10
- Removed@types/node@20.17.6(transitive)