@mongosh/service-provider-core
Advanced tools
Comparing version 0.8.3 to 0.9.0
@@ -7,2 +7,3 @@ export default interface CliOptions { | ||
awsAccessKeyId?: string; | ||
awsIamSessionToken?: string; | ||
awsSecretAccessKey?: string; | ||
@@ -9,0 +10,0 @@ awsSessionToken?: string; |
@@ -54,3 +54,11 @@ "use strict"; | ||
function generateUri(options) { | ||
return generateUriNormalized(options).toString(); | ||
const connectionString = generateUriNormalized(options); | ||
if (connectionString.hosts.length === 1 && | ||
['localhost', '127.0.0.1'].includes(connectionString.hosts[0].split(':')[0])) { | ||
const params = connectionString.searchParams; | ||
if (!params.has('serverSelectionTimeoutMS')) { | ||
params.set('serverSelectionTimeoutMS', '2000'); | ||
} | ||
} | ||
return connectionString.toString(); | ||
} | ||
@@ -57,0 +65,0 @@ function generateUriNormalized(options) { |
{ | ||
"name": "@mongosh/service-provider-core", | ||
"version": "0.8.3", | ||
"version": "0.9.0", | ||
"description": "MongoDB Shell Core Service Provider Package", | ||
@@ -30,4 +30,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@mongosh/errors": "0.8.3", | ||
"@mongosh/i18n": "0.8.3", | ||
"@mongosh/errors": "0.9.0", | ||
"@mongosh/i18n": "0.9.0", | ||
"bson": "^4.2.3", | ||
@@ -56,3 +56,3 @@ "mongodb": "4.0.0-beta.1", | ||
}, | ||
"gitHead": "074ca99cb2761198041089e6d8bf01a8c8ffabc7" | ||
"gitHead": "be8b2a857c1a6ea05ec598273c68b4703d7c5a54" | ||
} |
@@ -10,2 +10,3 @@ /** | ||
awsAccessKeyId?: string; | ||
awsIamSessionToken?: string; | ||
awsSecretAccessKey?: string; | ||
@@ -12,0 +13,0 @@ awsSessionToken?: string; |
@@ -10,3 +10,3 @@ import { CommonErrors, MongoshInvalidInputError } from '@mongosh/errors'; | ||
it('returns the default uri', () => { | ||
expect(generateUri(options)).to.equal('mongodb://127.0.0.1:27017/?directConnection=true'); | ||
expect(generateUri(options)).to.equal('mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
@@ -17,12 +17,12 @@ }); | ||
it('handles host', () => { | ||
expect(generateUri({ _: [], host: 'localhost' })).to.equal('mongodb://localhost:27017/?directConnection=true'); | ||
expect(generateUri({ _: [], host: 'localhost' })).to.equal('mongodb://localhost:27017/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
it('handles port', () => { | ||
expect(generateUri({ _: [], port: '27018' })).to.equal('mongodb://127.0.0.1:27018/?directConnection=true'); | ||
expect(generateUri({ _: [], port: '27018' })).to.equal('mongodb://127.0.0.1:27018/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
it('handles both host and port', () => { | ||
expect(generateUri({ _: [], host: 'localhost', port: '27018' })).to.equal('mongodb://localhost:27018/?directConnection=true'); | ||
expect(generateUri({ _: [], host: 'localhost', port: '27018' })).to.equal('mongodb://localhost:27018/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
it('handles host with port included', () => { | ||
expect(generateUri({ _: [], host: 'localhost:27018' })).to.equal('mongodb://localhost:27018/?directConnection=true'); | ||
expect(generateUri({ _: [], host: 'localhost:27018' })).to.equal('mongodb://localhost:27018/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
@@ -39,3 +39,3 @@ it('throws if host has port AND port set to other value', () => { | ||
it('handles host has port AND port set to equal value', () => { | ||
expect(generateUri({ _: [], host: 'localhost:27018', port: '27018' })).to.equal('mongodb://localhost:27018/?directConnection=true'); | ||
expect(generateUri({ _: [], host: 'localhost:27018', port: '27018' })).to.equal('mongodb://localhost:27018/?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
@@ -234,3 +234,3 @@ }); | ||
it('uses the provided host with default port', () => { | ||
expect(generateUri(options)).to.equal('mongodb://127.0.0.1:27018/foo?directConnection=true'); | ||
expect(generateUri(options)).to.equal('mongodb://127.0.0.1:27018/foo?directConnection=true&serverSelectionTimeoutMS=2000'); | ||
}); | ||
@@ -237,0 +237,0 @@ }); |
@@ -128,3 +128,11 @@ /* eslint complexity: 0*/ | ||
function generateUri(options: CliOptions): string { | ||
return generateUriNormalized(options).toString(); | ||
const connectionString = generateUriNormalized(options); | ||
if (connectionString.hosts.length === 1 && | ||
['localhost', '127.0.0.1'].includes(connectionString.hosts[0].split(':')[0])) { | ||
const params = connectionString.searchParams; | ||
if (!params.has('serverSelectionTimeoutMS')) { | ||
params.set('serverSelectionTimeoutMS', '2000'); | ||
} | ||
} | ||
return connectionString.toString(); | ||
} | ||
@@ -131,0 +139,0 @@ function generateUriNormalized(options: CliOptions): ConnectionString { |
Sorry, the diff of this file is not supported yet
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
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
124856
2676
+ Added@mongosh/errors@0.9.0(transitive)
+ Added@mongosh/i18n@0.9.0(transitive)
- Removed@mongosh/errors@0.8.3(transitive)
- Removed@mongosh/i18n@0.8.3(transitive)
Updated@mongosh/errors@0.9.0
Updated@mongosh/i18n@0.9.0