feat(Google Cloud Realtime Database Node): Make it possible to select region (#3096)

* upstream merge

* 🔨 fixed bug, replaced icon with svg, added ability to get whole db object

* 🔨 optimization

* 🔨 option for region in credentials

* 🐛 Fix region default

*  Remove dot

Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Michael Kret
2022-04-14 10:19:45 +03:00
committed by GitHub
parent 3e5d981f3f
commit 176538e5f2
5 changed files with 101 additions and 11 deletions

View File

@@ -9,11 +9,13 @@ import {
} from 'n8n-core';
import {
IDataObject, NodeApiError,
IDataObject, JsonObject, NodeApiError,
} from 'n8n-workflow';
export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, projectId: string, method: string, resource: string, body: any = {}, qs: IDataObject = {}, headers: IDataObject = {}, uri: string | null = null): Promise<any> { // tslint:disable-line:no-any
const { region } = await this.getCredentials('googleFirebaseRealtimeDatabaseOAuth2Api') as IDataObject;
const options: OptionsWithUrl = {
headers: {
'Content-Type': 'application/json',
@@ -21,9 +23,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
method,
body,
qs,
url: uri || `https://${projectId}.firebaseio.com/${resource}.json`,
url: uri || `https://${projectId}.${region}/${resource}.json`,
json: true,
};
try {
if (Object.keys(headers).length !== 0) {
options.headers = Object.assign({}, options.headers, headers);
@@ -34,7 +37,7 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF
return await this.helpers.requestOAuth2!.call(this, 'googleFirebaseRealtimeDatabaseOAuth2Api', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
throw new NodeApiError(this.getNode(), error as JsonObject);
}
}