mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2026-03-27 09:28:43 +07:00
Update docs to stop using n8n-core and request (#2609)
This commit is contained in:
committed by
GitHub
parent
20ea69c03d
commit
9c5010359e
@@ -57,20 +57,17 @@ After the repo gets cloned, open the package.json file, and update the value of
|
||||
Open the cloned repository in your code editor, and create a new folder called `Weather`, inside the ***nodes*** folder. Create `Weather.node.ts` file inside the Weather folder and paste the following code:
|
||||
|
||||
```ts
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IRequestOptions,
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
export class Weather implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Weather',
|
||||
@@ -328,7 +325,7 @@ export class Weather implements INodeType {
|
||||
throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`);
|
||||
}
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
method: 'GET',
|
||||
qs,
|
||||
uri: `https://api.openweathermap.org/data/2.5/${endpoint}`,
|
||||
@@ -487,11 +484,11 @@ If you're running n8n via Docker, you will have to create a Docker image with th
|
||||
4. Build your Docker image:
|
||||
|
||||
```Dockerfile
|
||||
# Replace <n8n-version-number> with the n8n release version number.
|
||||
# Replace <n8n-version-number> with the n8n release version number.
|
||||
# For example, N8N_VERSION=0.177.0
|
||||
docker build --build-arg N8N_VERSION=<n8n-version-number> --tag=customizedn8n .
|
||||
```
|
||||
|
||||
You can now use your n8n-nodes-module in Docker.
|
||||
|
||||
If you're running either by installing it globally or using PM2, make sure that you install your n8n-nodes-module inside n8n. n8n will find the module and load it automatically.
|
||||
If you're running either by installing it globally or using PM2, make sure that you install your n8n-nodes-module inside n8n. n8n will find the module and load it automatically.
|
||||
|
||||
@@ -46,15 +46,12 @@ Since n8n's repository already has a Autopilot Trigger node, we will name this n
|
||||
5. Paste the following code in the `AutofriendTrigger.node.ts` file.
|
||||
|
||||
```typescript
|
||||
import {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IHookFunctions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookFunctions,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -335,18 +332,12 @@ Let's see how this would look for our current use-case:
|
||||
1. Go to `packages/nodes-base/nodes/Autofriend`, create a file named `GenericFunctions.ts`, and paste the following code.
|
||||
|
||||
```typescript
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
@@ -358,7 +349,7 @@ export async function autofriendApiRequest(this: IExecuteFunctions | IWebhookFun
|
||||
|
||||
const endpoint = 'https://api2.autopilothq.com/v1';
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
autopilotapikey: apiKey,
|
||||
|
||||
@@ -5,7 +5,7 @@ contentType: explanation
|
||||
|
||||
# Choose your node building approach
|
||||
|
||||
n8n has two node-building styles, declarative and programmatic.
|
||||
n8n has two node-building styles, declarative and programmatic.
|
||||
|
||||
You should use the declarative style for most nodes. This style:
|
||||
|
||||
@@ -31,8 +31,13 @@ To understand the difference between the declarative and programmatic styles, co
|
||||
In programmatic style:
|
||||
|
||||
```js
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
// Create the FriendGrid class
|
||||
export class FriendGrid implements INodeType {
|
||||
@@ -98,7 +103,7 @@ export class FriendGrid implements INodeType {
|
||||
Object.assign(data, additionalFields);
|
||||
|
||||
// Make HTTP request as defined in https://sendgrid.com/docs/api-reference/
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${credentials.apiKey}`,
|
||||
@@ -158,7 +163,7 @@ export class FriendGrid implements INodeType {
|
||||
value: 'create',
|
||||
description: 'Create a contact',
|
||||
// Add the routing object
|
||||
routing: {
|
||||
routing: {
|
||||
request: {
|
||||
method: 'POST',
|
||||
url: '=/contacts',
|
||||
|
||||
Reference in New Issue
Block a user