From 2598d7fec9501cf72a3271f56b554ec75f81ed44 Mon Sep 17 00:00:00 2001 From: Colin Sagan Date: Fri, 14 Sep 2018 22:41:28 -0300 Subject: [PATCH 1/2] More robust parsing of mongodb connection string. Use new url parser. --- .../generators/connection/templates/mongodb.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/generator-feathers/generators/connection/templates/mongodb.js b/packages/generator-feathers/generators/connection/templates/mongodb.js index 006bc2293f..0f96be6176 100644 --- a/packages/generator-feathers/generators/connection/templates/mongodb.js +++ b/packages/generator-feathers/generators/connection/templates/mongodb.js @@ -1,15 +1,15 @@ -const url = require('url'); +const parse = require('mongodb-core').parseConnectionString; const MongoClient = require('mongodb').MongoClient; module.exports = function (app) { const config = app.get('mongodb'); - const dbName = url.parse(config).path.substring(1); - const promise = MongoClient.connect(config).then(client => { + const promise = MongoClient.connect(config, { useNewUrlParser: true }).then(client => { // For mongodb <= 2.2 if(client.collection) { return client; } - + + const dbName = parse(config, () => {}); return client.db(dbName); }); From d128044998810f0786765a1e949b0a8a927de077 Mon Sep 17 00:00:00 2001 From: Colin Sagan Date: Tue, 18 Sep 2018 17:44:31 -0300 Subject: [PATCH 2/2] Set mongodb-core as a dependency when generating a mongodb connection --- packages/generator-feathers/generators/connection/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/generator-feathers/generators/connection/index.js b/packages/generator-feathers/generators/connection/index.js index ae39a458f3..84c78a00d3 100644 --- a/packages/generator-feathers/generators/connection/index.js +++ b/packages/generator-feathers/generators/connection/index.js @@ -68,6 +68,7 @@ module.exports = class ConnectionGenerator extends Generator { case 'mongodb': this.dependencies.push(adapter); + this.dependencies.push('mongodb-core'); return connectionString; case 'mysql':