mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 22:54:05 -08:00
0ecbb4a19d
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
43 lines
987 B
TypeScript
43 lines
987 B
TypeScript
import { OptionsWithUri } from 'request';
|
|
|
|
import { IExecuteFunctions } from 'n8n-core';
|
|
|
|
import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow';
|
|
|
|
import { ElasticsearchApiCredentials } from './types';
|
|
|
|
export async function elasticsearchApiRequest(
|
|
this: IExecuteFunctions,
|
|
method: 'GET' | 'PUT' | 'POST' | 'DELETE',
|
|
endpoint: string,
|
|
body: IDataObject = {},
|
|
qs: IDataObject = {},
|
|
) {
|
|
const { baseUrl, ignoreSSLIssues } = (await this.getCredentials(
|
|
'elasticsearchApi',
|
|
)) as ElasticsearchApiCredentials;
|
|
|
|
const options: OptionsWithUri = {
|
|
method,
|
|
body,
|
|
qs,
|
|
uri: `${baseUrl}${endpoint}`,
|
|
json: true,
|
|
rejectUnauthorized: !ignoreSSLIssues,
|
|
};
|
|
|
|
if (!Object.keys(body).length) {
|
|
delete options.body;
|
|
}
|
|
|
|
if (!Object.keys(qs).length) {
|
|
delete options.qs;
|
|
}
|
|
|
|
try {
|
|
return await this.helpers.requestWithAuthentication.call(this, 'elasticsearchApi', options);
|
|
} catch (error) {
|
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
|
}
|
|
}
|