Skip to content

Commit 15f5e57

Browse files
authored
Merge pull request #43 from seanstern/fix-monogodb-vulnerability
Update mongodb dependency to ^3.2.7
2 parents 4424bb2 + ef7aa7d commit 15f5e57

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

providers/workflow-es-mongodb/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "workflow-es-mongodb",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "MongoDB provider for Workflow ES",
55
"main": "./build/src/index.js",
66
"typings": "./build/src/index.d.ts",
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"inversify": "^4.1.0",
3131
"json-stable-stringify": "^1.0.1",
32-
"mongodb": "^2.2.11",
32+
"mongodb": "^3.2.7",
3333
"reflect-metadata": "^0.1.10",
3434
"workflow-es": "^2.1.0"
3535
},

providers/workflow-es-mongodb/src/mongodb-provider.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MongoClient, ObjectID } from "mongodb";
44
export class MongoDBPersistence implements IPersistenceProvider {
55

66
public connect: Promise<void>;
7-
private db: any;
7+
private client: any;
88
private workflowCollection: any;
99
private subscriptionCollection: any;
1010
private eventCollection: any;
@@ -13,14 +13,16 @@ export class MongoDBPersistence implements IPersistenceProvider {
1313

1414
constructor(connectionString: string) {
1515
var self = this;
16-
this.connect = new Promise<void>((resolve, reject) => {
17-
MongoClient.connect(connectionString, (err, db) => {
16+
this.connect = new Promise<void>((resolve, reject) => {
17+
const options = { useNewUrlParser: true, useUnifiedTopology: true };
18+
MongoClient.connect(connectionString, options, (err, client) => {
1819
if (err)
1920
reject(err);
20-
self.db = db;
21-
self.workflowCollection = self.db.collection("workflows");
22-
self.subscriptionCollection = self.db.collection("subscriptions");
23-
self.eventCollection = self.db.collection("events");
21+
self.client = client;
22+
const db = self.client.db();
23+
self.workflowCollection = db.collection("workflows");
24+
self.subscriptionCollection = db.collection("subscriptions");
25+
self.eventCollection = db.collection("events");
2426
resolve();
2527
});
2628
});

0 commit comments

Comments
 (0)