mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Load credentials from the database (#1741)
* Changes to types so that credentials can be always loaded from DB This first commit changes all return types from the execute functions and calls to get credentials to be async so we can use await. This is a first step as previously credentials were loaded in memory and always available. We will now be loading them from the DB which requires turning the whole call chain async. * Fix updated files * Removed unnecessary credential loading to improve performance * Fix typo * ⚡ Fix issue * Updated new nodes to load credentials async * ⚡ Remove not needed comment Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -277,7 +277,7 @@ export class HubspotTrigger implements INodeType {
|
||||
// Check all the webhooks which exist already if it is identical to the
|
||||
// one that is supposed to get created.
|
||||
const currentWebhookUrl = this.getNodeWebhookUrl('default') as string;
|
||||
const { appId } = this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
|
||||
try {
|
||||
const { targetUrl } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/settings`, {});
|
||||
@@ -304,7 +304,7 @@ export class HubspotTrigger implements INodeType {
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const { appId } = this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
const events = (this.getNodeParameter('eventsUi') as IDataObject || {}).eventValues as IDataObject[] || [];
|
||||
const additionalFields = this.getNodeParameter('additionalFields') as IDataObject;
|
||||
let endpoint = `/webhooks/v3/${appId}/settings`;
|
||||
@@ -336,7 +336,7 @@ export class HubspotTrigger implements INodeType {
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const { appId } = this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
const { appId } = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
|
||||
const { results: subscriptions } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/subscriptions`, {});
|
||||
|
||||
@@ -356,7 +356,7 @@ export class HubspotTrigger implements INodeType {
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
|
||||
const credentials = this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
const credentials = await this.getCredentials('hubspotDeveloperApi') as IDataObject;
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No credentials found!');
|
||||
|
||||
Reference in New Issue
Block a user