mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
⚡ Small improvements to Mongo connection string support
This commit is contained in:
@@ -7,7 +7,8 @@ export interface IMongoParametricCredentials {
|
||||
/**
|
||||
* Whether to allow overriding the parametric credentials with a connection string
|
||||
*/
|
||||
shouldOverrideConnString: false | undefined | null;
|
||||
configurationType: 'values';
|
||||
|
||||
host: string;
|
||||
database: string;
|
||||
user: string;
|
||||
@@ -22,11 +23,11 @@ export interface IMongoOverrideCredentials {
|
||||
/**
|
||||
* Whether to allow overriding the parametric credentials with a connection string
|
||||
*/
|
||||
shouldOverrideConnString: true;
|
||||
configurationType: 'connectionString';
|
||||
/**
|
||||
* If using an override connection string, this is where it will be.
|
||||
*/
|
||||
connStringOverrideVal: string;
|
||||
connectionString: string;
|
||||
database: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ function buildMongoConnectionParams(
|
||||
credentials.database && credentials.database.trim().length > 0
|
||||
? credentials.database.trim()
|
||||
: '';
|
||||
if (credentials.shouldOverrideConnString) {
|
||||
if (credentials.configurationType === 'connectionString') {
|
||||
if (
|
||||
credentials.connStringOverrideVal &&
|
||||
credentials.connStringOverrideVal.trim().length > 0
|
||||
credentials.connectionString &&
|
||||
credentials.connectionString.trim().length > 0
|
||||
) {
|
||||
return {
|
||||
connectionString: credentials.connStringOverrideVal.trim(),
|
||||
connectionString: credentials.connectionString.trim(),
|
||||
database: sanitizedDbName
|
||||
};
|
||||
} else {
|
||||
@@ -67,11 +67,11 @@ function buildMongoConnectionParams(
|
||||
export function validateAndResolveMongoCredentials(
|
||||
credentials?: ICredentialDataDecryptedObject
|
||||
): IMongoCredentials {
|
||||
if (credentials == undefined) {
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
} else {
|
||||
return buildMongoConnectionParams(
|
||||
(credentials as any) as IMongoCredentialsType
|
||||
credentials as unknown as IMongoCredentialsType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user