### Basic GET Request Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Demonstrates how to perform a basic GET request using axios, with examples using both async/await and Promises. ```APIDOC ## GET /user ### Description Performs a GET request to retrieve user data. ### Method GET ### Endpoint /user ### Query Parameters - **ID** (string) - Required - The ID of the user to retrieve. ### Request Example ```javascript // Using async/await async function getUser(userId) { try { const response = await axios.get(`/user?ID=${userId}`); console.log(response.data); } catch (error) { console.error(error); } } // Using Promises axios.get('/user', { params: { ID: '12345' } }) .then(function (response) { console.log(response.data); }) .catch(function (error) { console.error(error); }); ``` ### Response #### Success Response (200) - **data** (object) - The user data. #### Response Example ```json { "id": "12345", "name": "John Doe" } ``` ``` -------------------------------- ### Basic Hono Server Setup in Node.js Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/playwright-core/ThirdPartyNotices.txt Provides a fundamental example of setting up a Hono application to run on Node.js using the @hono/node-server package. It shows how to import necessary modules, define a simple route, and start the server. ```typescript import { serve } from '@hono/node-server' import { Hono } from 'hono' const app = new Hono() app.get('/', (c) => c.text('Hono meets Node.js')) serve(app, (info) => { console.log(`Listening on http://localhost:${info.port}`) }) ``` -------------------------------- ### Project Setup and Launch Commands Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Provides essential commands for setting up, launching, and managing the n8n-nodes-brainiall project. This includes installing dependencies, bootstrapping the workspace, starting and stopping Docker services, running tests, and cleaning the project. ```bash # Install project dependencies yarn # Install all workspace dependencies yarn bootstrap # Start Docker services yarn test:services:start # Stop Docker services yarn test:services:stop # Run all tests yarn test # Remove yarn and dependencies yarn clean ``` -------------------------------- ### POST /api/upload - File Uploads Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Examples of uploading single and multiple files using Axios's `postForm` shortcut method. ```APIDOC ## POST /api/upload - File Uploads ### Description Easily upload single or multiple files using the `axios.postForm` shortcut, which sets `Content-Type` to `multipart/form-data`. ### Method POST ### Endpoint `/api/upload` ### Parameters #### Request Body - **data** (object) - Required - An object containing form fields and file(s). - For a single file, use a key like `file`. - For multiple files, use an array-like key like `files[]` or pass a `FileList` object directly. ### Request Example **Single File Upload:** ```javascript await axios.postForm("https://httpbin.org/post", { myVar: "foo", file: document.querySelector("#fileInput").files[0], }); ``` **Multiple Files Upload:** ```javascript await axios.postForm("https://httpbin.org/post", { "files[]": document.querySelector("#fileInput").files, }); ``` **Uploading FileList Object Directly:** ```javascript await axios.postForm( "https://httpbin.org/post", document.querySelector("#fileInput").files, ); ``` ### Response #### Success Response (200) - **data** (object) - The response from the server, including details of the uploaded files. #### Response Example ```json { "args": {}, "data": "", "files": { "file": "...content of the file..." }, "form": { "myVar": "foo" }, "headers": { "content-length": "...", "content-type": "multipart/form-data; boundary=..." }, "json": null, "origin": "...", "url": "https://httpbin.org/post" } ``` ``` -------------------------------- ### Making GET Requests with Axios (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Demonstrates how to perform GET requests using Axios, including both async/await and Promise-based approaches. It shows basic usage and error handling. Note that async/await requires ECMAScript 2017 support. ```javascript import axios from "axios"; //const axios = require('axios'); // legacy way try { const response = await axios.get("/user?ID=12345"); console.log(response); } catch (error) { console.error(error); } // Optionally the request above could also be done asaxios .get("/user", { params: { ID: 12345, }, }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) .finally(function () { // always executed }); // Want to use async/await? Add the `async` keyword to your outer function/method. async function getUser() { try { const response = await axios.get("/user?ID=12345"); console.log(response); } catch (error) { console.error(error); } } ``` -------------------------------- ### Creating Custom Axios Instance Defaults (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Shows how to create a custom Axios instance with specific default configurations, such as a base URL. It also demonstrates how to modify these defaults after the instance has been created, allowing for flexible request setup. ```javascript // Set config defaults when creating the instance const instance = axios.create({ baseURL: "https://api.example.com", }); // Alter defaults after instance has been created instance.defaults.headers.common["Authorization"] = AUTH_TOKEN; ``` -------------------------------- ### Making POST Requests with Axios (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Illustrates how to send a POST request using Axios. This example shows how to send data in the request body and handle the response. It utilizes the async/await syntax for cleaner asynchronous code. ```javascript const response = await axios.post("/user", { firstName: "Fred", lastName: "Flintstone", }); console.log(response); ``` -------------------------------- ### Import Axios Browser/Node CommonJS Bundles Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Provides examples for importing specific CommonJS bundles of Axios, useful for custom or legacy environments. It shows how to import the browser or Node.js specific CommonJS bundles. ```javascript const axios = require("axios/dist/browser/axios.cjs"); // browser commonJS bundle (ES2017) ``` ```javascript // const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017) ``` -------------------------------- ### MockClient Request Example (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/undici/docs/docs/api/MockClient.md Shows a practical example of using MockClient to intercept and respond to a GET request. It sets up an intercept for '/foo', makes the request, and then logs the status code and response body. ```javascript import { MockAgent } from 'undici' const mockAgent = new MockAgent({ connections: 1 }) const mockClient = mockAgent.get('http://localhost:3000') mockClient.intercept({ path: '/foo' }).reply(200, 'foo') const { statusCode, body } = await mockClient.request({ origin: 'http://localhost:3000', path: '/foo', method: 'GET' }) console.log('response received', statusCode) // response received 200 for await (const data of body) { console.log('data', data.toString('utf8')) // data foo } ``` -------------------------------- ### Initialize Keyv with Different Backends Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Demonstrates initializing a Keyv instance with various storage adapters using connection strings. It also shows how to handle database connection errors. ```javascript const Keyv = require('keyv'); // One of the following const keyv = new Keyv(); const keyv = new Keyv('redis://user:pass@localhost:6379'); const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname'); const keyv = new Keyv('sqlite://path/to/database.sqlite'); const keyv = new Keyv('postgresql://user:pass@localhost:5432/dbname'); const keyv = new Keyv('mysql://user:pass@localhost:3306/dbname'); const keyv = new Keyv('etcd://localhost:2379'); // Handle DB connection errors keyv.on('error', err => console.log('Connection Error', err)); ``` -------------------------------- ### Axios Fetch Adapter with Tauri Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Example of configuring Axios to use the fetch adapter with Tauri's platform fetch function, which bypasses CORS policy. This setup is suitable for Tauri applications requiring specific network request handling. ```javascript import { fetch } from "@tauri-apps/plugin-http"; import axios from "axios"; const instance = axios.create({ adapter: "fetch", onDownloadProgress(e) { console.log("downloadProgress", e); }, env: { fetch, }, }); const { data } = await instance.get("https://google.com"); ``` -------------------------------- ### Axios API: Simplified GET Request (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Illustrates the simplest way to make a GET request using Axios by just providing the URL. The `axios(url)` shorthand defaults to the GET method, making common GET requests concise. ```javascript // Send a GET request (default method) axios("/user/12345"); ``` -------------------------------- ### POST /api/upload - Node.js FormData Usage Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Example of sending multipart/form-data in a Node.js environment using the 'form-data' library. ```APIDOC ## POST /api/upload - Node.js ### Description Send data as `multipart/form-data` in Node.js using the `form-data` library, including buffers and files. ### Method POST ### Endpoint `/api/upload` ### Parameters #### Request Body - **form** (FormData) - Required - An instance of FormData containing the data to be sent. ### Request Example ```javascript const FormData = require("form-data"); const fs = require("fs"); const form = new FormData(); form.append("my_field", "my value"); form.append("my_buffer", Buffer.alloc(10)); form.append("my_file", fs.createReadStream("/foo/bar.jpg")); axios.post("https://example.com", form); ``` ### Response #### Success Response (200) - **data** (object) - The response from the server. #### Response Example (Response will vary based on the server implementation) ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/fill-range/README.md To set up the project and run its tests, you need to install the dependencies using npm and then execute the test command. This is a standard procedure for verifying the functionality and integrity of the library. ```bash $ npm install && npm test ``` -------------------------------- ### Getting Header Values with AxiosHeaders#get (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Illustrates various ways to use the `get` method of AxiosHeaders to retrieve header values. It includes retrieving raw values, parsing key-value pairs, applying custom transformations, and using regular expressions for extraction. ```js const headers = new AxiosHeaders({ "Content-Type": "multipart/form-data; boundary=Asrf456BGe4h", }); console.log(headers.get("Content-Type")); // multipart/form-data; boundary=Asrf456BGe4h console.log(headers.get("Content-Type", true)); // parse key-value pairs from a string separated with \s,;= delimiters: // [Object: null prototype] { // 'multipart/form-data': undefined, // boundary: 'Asrf456BGe4h' // } console.log( headers.get("Content-Type", (value, name, headers) => { return String(value).replace(/a/g, "ZZZ"); }), ); // multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h console.log(headers.get("Content-Type", /boundary=(\w+)/)?.[0]); // boundary=Asrf456BGe4h ``` -------------------------------- ### Install Keyv and Storage Adapters Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Install the core Keyv package and optional storage adapters for different databases like Redis, MongoDB, SQLite, PostgreSQL, MySQL, and Etcd. ```bash npm install --save keyv npm install --save @keyv/redis npm install --save @keyv/mongo npm install --save @keyv/sqlite npm install --save @keyv/postgres npm install --save @keyv/mysql npm install --save @keyv/etcd ``` -------------------------------- ### Client Constructor and Options Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/undici/docs/docs/api/Client.md Details on how to instantiate the Client class and the various options available for configuring its behavior, including timeouts, connection settings, and request limits. ```APIDOC ## Client Class Extends: `undici.Dispatcher` A basic HTTP/1.1 client, mapped on a single TCP/TLS connection. Pipelining is disabled by default. Requests are not guaranteed to be dispatched in order of invocation. ### `new Client(url[, options])` Arguments: * **url** `URL | string` - Should only include the **protocol, hostname, and port**. * **options** `ClientOptions` (optional) Returns: `Client` ### Parameter: `ClientOptions` > ⚠️ Warning: The `H2` support is experimental. * **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. Please note the `timeout` will be reset if you keep writing data to the scoket everytime. * **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Defaults to 10 minutes. * **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds. * **keepAliveTimeoutThreshold** `number | null` (optional) - Default: `2e3` - A number of milliseconds subtracted from server *keep-alive* hints when overriding `keepAliveTimeout` to account for timing inaccuracies caused by e.g. transport latency. Defaults to 2 seconds. * **maxHeaderSize** `number | null` (optional) - Default: `--max-http-header-size` or `16384` - The maximum length of request headers in bytes. Defaults to Node.js' --max-http-header-size or 16KiB. * **maxResponseSize** `number | null` (optional) - Default: `-1` - The maximum length of response body in bytes. Set to `-1` to disable. * **pipelining** `number | null` (optional) - Default: `1` - The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Carefully consider your workload and environment before enabling concurrent requests as pipelining may reduce performance if used incorrectly. Pipelining is sensitive to network stack settings as well as head of line blocking caused by e.g. long running requests. Set to `0` to disable keep-alive connections. * **connect** `ConnectOptions | Function | null` (optional) - Default: `null`. * **strictContentLength** `Boolean` (optional) - Default: `true` - Whether to treat request content length mismatches as errors. If true, an error is thrown when the request content-length header doesn't match the length of the request body. * **interceptors** `{ Client: DispatchInterceptor[] }` - Default: `[RedirectInterceptor]` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching). Note that the behavior of interceptors is Experimental and might change at any given time. **Note: this is deprecated in favor of [Dispatcher#compose](./Dispatcher.md#dispatcher). Support will be droped in next major.** * **autoSelectFamily**: `boolean` (optional) - Default: depends on local Node version, on Node 18.13.0 and above is `false`. Enables a family autodetection algorithm that loosely implements section 5 of [RFC 8305](https://tools.ietf.org/html/rfc8305#section-5). See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. This option is ignored if not supported by the current Node version. * **autoSelectFamilyAttemptTimeout**: `number` - Default: depends on local Node version, on Node 18.13.0 and above is `250`. The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. * **allowH2**: `boolean` - Default: `false`. Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation. * **maxConcurrentStreams**: `number` - Default: `100`. Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame. ``` -------------------------------- ### Axios FormData Serializer Example Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Provides an example of a complex JavaScript object and its corresponding FormData representation as processed by Axios's internal serializer. It highlights how nested objects, arrays, and special key endings are handled. ```javascript const obj = { x: 1, arr: [1, 2, 3], arr2: [1, [2], 3], users: [ { name: "Peter", surname: "Griffin" }, { name: "Thomas", surname: "Anderson" }, ], "obj2{}": [{ x: 1 }], }; // Internal Axios processing would result in: // const formData = new FormData(); // formData.append("x", "1"); // formData.append("arr[]", "1"); // formData.append("arr[]", "2"); // formData.append("arr[]", "3"); // formData.append("arr2[0]", "1"); // formData.append("arr2[1][0]", "2"); // formData.append("arr2[2]", "3"); // formData.append("users[0][name]", "Peter"); // formData.append("users[0][surname]", "Griffin"); // formData.append("users[1][name]", "Thomas"); // formData.append("users[1][surname]", "Anderson"); // formData.append("obj2{}", '[{"x":1}]'); ``` -------------------------------- ### Node.js Installation for Neo-Async (Replacement) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/neo-async/README.md This demonstrates how to install Neo-Async and then create a symbolic link to replace the 'async' module. This allows existing code that requires 'async' to use Neo-Async without modification. ```bash $ npm install neo-async $ ln -s ./node_modules/neo-async ./node_modules/async ``` ```javascript var async = require('async'); ``` -------------------------------- ### Axios Configuration Precedence Example Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Demonstrates how Axios configurations are merged. Library defaults are overridden by instance defaults, which are then overridden by request-specific configurations. This example shows setting a default timeout for an instance and then overriding it for a specific request. ```javascript const instance = axios.create(); // Override timeout default for the library // Now all requests using this instance will wait 2.5 seconds before timing out instance.defaults.timeout = 2500; // Override timeout for this request as it's known to take a long time instance.get("/longRequest", { timeout: 5000, }); ``` -------------------------------- ### Client Instantiation Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/undici/docs/docs/api/Client.md Demonstrates how to instantiate the Undici Client with basic and custom connector options. ```APIDOC ## Client Instantiation ### Description Instantiates the undici Client. The client will not connect to the origin until a request is queued or `client.connect` is explicitly called. ### Basic Client Instantiation ```js 'use strict' import { Client } from 'undici' const client = new Client('http://localhost:3000') ``` ### Custom Connector Allows for additional checks on the socket before it's used for a request. ```js 'use strict' import { Client, buildConnector } from 'undici' const connector = buildConnector({ rejectUnauthorized: false }) const client = new Client('https://localhost:3000', { connect (opts, cb) { connector(opts, (err, socket) => { if (err) { cb(err) } else if (/* assertion */) { socket.destroy() cb(new Error('kaboom')) } else { cb(null, socket) } }) } }) ``` ### Connect Options Every Tls option, see [here](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback). Furthermore, the following options can be passed: * **socketPath** `string | null` (optional) - Default: `null` - An IPC endpoint, either Unix domain socket or Windows named pipe. * **maxCachedSessions** `number | null` (optional) - Default: `100` - Maximum number of TLS cached sessions. Use 0 to disable TLS session caching. * **timeout** `number | null` (optional) - In milliseconds, Default `10e3`. * **servername** `string | null` (optional) * **keepAlive** `boolean | null` (optional) - Default: `true` - TCP keep-alive enabled * **keepAliveInitialDelay** `number | null` (optional) - Default: `60000` - TCP keep-alive interval for the socket in milliseconds ``` -------------------------------- ### Axios Instance Creation Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Explains how to create a custom Axios instance with predefined configurations like baseURL and timeout. ```APIDOC ## Create Axios Instance ### Description Creates a reusable Axios instance with custom default configurations, such as base URL, timeout, and headers. ### Method `axios.create([config])` ### Parameters #### Config Object - **baseURL** (string) - Optional - The base URL to be prepended to requests. - **timeout** (number) - Optional - The number of milliseconds before the request times out. - **headers** (object) - Optional - Default custom headers to be sent with requests. ### Request Example ```javascript const apiClient = axios.create({ baseURL: 'https://api.example.com/v1/', timeout: 5000, headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'X-Custom-Header': 'foobar' } }); // Using the instance async function getProducts() { try { const response = await apiClient.get('/products'); console.log(response.data); } catch (error) { console.error(error); } } ``` ### Instance Methods Instances created with `axios.create` have the same methods as the global `axios` object (e.g., `get`, `post`, `request`), but they will use the instance's configuration. ``` -------------------------------- ### AxiosHeaders Class Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Provides methods for creating and manipulating HTTP headers, including setting, getting, deleting, and clearing headers with advanced control over merging and overwriting. ```APIDOC ## AxiosHeaders Class ### Description The `AxiosHeaders` class is used to manage HTTP headers. It allows for flexible handling of header values, including strings, null, false, and undefined, each with specific implications for network transmission and merging logic. The class provides methods to set, get, check for existence, delete, and clear headers, with options to control overwriting behavior. ### Constructor ```ts new AxiosHeaders(headers?: RawAxiosHeaders | AxiosHeaders | string) ``` Constructs a new `AxiosHeaders` instance. The `headers` argument can be an object, another `AxiosHeaders` instance, or a string representing raw HTTP headers. #### Example ```js // From an object const headers1 = new AxiosHeaders({ "Content-Type": "application/json" }); // From raw HTTP headers string const headers2 = new AxiosHeaders(` Host: www.example.com User-Agent: curl/7.54.0 Accept: */* `); ``` ### Methods #### `set(headerName, value, rewrite?)` Sets a header's value. The `rewrite` argument controls overwriting behavior: - `false`: Do not overwrite if the header's value is already set (not `undefined`). - `undefined` (default): Overwrite the header unless its value is `false`. - `true`: Always overwrite the header. A user-defined function can also be provided for `rewrite` to determine if the value should be overwritten. ```ts set(headerName: string, value: AxiosHeaderValue, rewrite?: boolean | ((this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean)); set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean); ``` Returns `this` for chaining. #### `get(headerName, matcher?)` Retrieves the internal value of a header. An optional `matcher` argument can be used to parse the header's value using a regular expression or a custom matching function. ```ts get(headerName: string, matcher?: true | AxiosHeaderMatcher | RegExp): AxiosHeaderValue | RegExpExecArray | null; ``` #### `has(headerName, matcher?)` Checks if a header is set (i.e., its value is not `undefined`). An optional `matcher` can be provided. ```ts has(headerName: string, matcher?: AxiosHeaderMatcher): boolean; ``` #### `delete(headerName, matcher?)` Removes a header or multiple headers. If a `matcher` is provided, it's used to match against the header name. ```ts delete(headerName: string | string[], matcher?: AxiosHeaderMatcher): boolean; ``` Returns `true` if at least one header was removed. #### `clear(matcher?)` Removes all headers. An optional `matcher` can be provided to filter which headers to clear, matching against the header name. ```ts clear(matcher?: AxiosHeaderMatcher): boolean; ``` Returns `true` if at least one header was cleared. #### `toJSON()` Returns the final headers object with string values, intended for network transmission. ```ts toSring(): RawAxiosHeaders; ``` ### Header Value Types - `string`: A normal string value to be sent to the server. - `null`: The header will be skipped when rendering to JSON. - `false`: The header will be skipped when rendering to JSON. It also indicates that the `set` method must be called with `rewrite` set to `true` to overwrite this value. - `undefined`: The value is not set. A header value is considered set if it is not equal to `undefined`. ``` -------------------------------- ### CLI UI Initialization with Options Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/@isaacs/cliui/README.md Shows how to initialize the cliui instance with specific configuration options. This includes setting the maximum width of the UI and enabling or disabling text wrapping. The first example demonstrates setting a fixed width, while the second shows how to control wrapping. ```javascript cliui = require('@isaacs/cliui') // Specify the maximum width of the UI being generated. const ui = cliui({ width: 60 }) // Enable or disable the wrapping of text in a column. const uiWithWrap = cliui({ wrap: false }) ``` -------------------------------- ### Request Configuration Options Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Details the various configuration options available for making HTTP requests. The `url` is mandatory, and requests default to `GET` if `method` is not specified. ```APIDOC ## Request Configuration Options These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. ### Method GET, POST, PUT, DELETE, etc. ### Endpoint N/A (Configuration object) ### Parameters #### Request Body (Configuration Object) - **url** (string) - Required - The server URL that will be used for the request. - **method** (string) - Optional - The request method to be used (e.g., 'get', 'post'). Defaults to 'get'. - **baseURL** (string) - Optional - A base URL to be prepended to `url` unless `url` is absolute and `allowAbsoluteUrls` is true. - **allowAbsoluteUrls** (boolean) - Optional - Determines if absolute URLs override `baseURL`. Defaults to true. - **transformRequest** (Array) - Optional - Functions to transform the request data before sending. Applicable for 'PUT', 'POST', 'PATCH', 'DELETE'. - **transformResponse** (Array) - Optional - Functions to transform the response data before passing to then/catch. - **headers** (object) - Optional - Custom headers to be sent with the request. - **params** (object) - Optional - URL parameters to be sent with the request. Must be a plain object or URLSearchParams. - **paramsSerializer** (object) - Optional - Configuration to customize the serialization of `params`. - **encode** (Function) - Optional - Custom encoder function for parameters. - **serialize** (Function) - Optional - Custom serializer function for the entire parameter object. - **indexes** (boolean | null) - Optional - Configuration for formatting array indexes in params. Options: false (default, empty brackets), true (brackets with indexes), null (no brackets). - **data** (any) - Optional - The data to be sent as the request body. Applicable for 'PUT', 'POST', 'DELETE', and 'PATCH'. Can be a string, object, ArrayBuffer, etc. - **timeout** (number) - Optional - The number of milliseconds before the request times out. Defaults to 0 (no timeout). - **withCredentials** (boolean) - Optional - Indicates if cross-site Access-Control requests should be made using credentials. Defaults to false. - **adapter** (string | Array | Function) - Optional - Allows custom handling of requests or specifies built-in adapters ('xhr', 'fetch', 'http'). - **auth** (object) - Optional - For HTTP Basic authentication. - **username** (string) - Required - The username for basic auth. - **password** (string) - Required - The password for basic auth. - **responseType** (string) - Optional - The type of data the server will respond with ('arraybuffer', 'document', 'json', 'text', 'stream', 'blob' - browser only). Defaults to 'json'. - **responseEncoding** (string) - Optional - Encoding to use for decoding responses (Node.js only, ignored for 'stream' or client-side requests). ### Request Example ```javascript { url: '/user', method: 'get', baseURL: 'https://some-domain.com/api/', headers: {'X-Requested-With': 'XMLHttpRequest'}, params: { ID: 12345 }, data: { firstName: 'Fred' }, timeout: 1000, auth: { username: 'janedoe', password: 's00pers3cret' }, responseType: 'json' } ``` ### Response #### Success Response (200) - **data** (any) - The response data from the server, transformed according to `transformResponse`. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Handle Axios Request Timeouts Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Provides an example of how to set a timeout for Axios requests and handle potential timeout errors. It uses `axios.isAxiosError` and checks for the `ECONNABORTED` error code. ```javascript async function fetchWithTimeout() { try { const response = await axios.get("https://example.com/data", { timeout: 5000, // 5 seconds }); console.log("Response:", response.data); } catch (error) { if (axios.isAxiosError(error) && error.code === "ECONNABORTED") { console.error("❌ Request timed out!"); } else { console.error("❌ Error:", error.message); } } } ``` -------------------------------- ### Install and Configure ESLint Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/eslint-plugin-n8n-nodes-base/node_modules/eslint/README.md This command installs and sets up ESLint in your project. It requires Node.js and will create an initial configuration file. ```shell npm init @eslint/config ``` -------------------------------- ### Using a Custom Third-Party Storage Adapter with Keyv Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Demonstrates how to initialize Keyv with a custom storage adapter. Any adapter implementing the Map API is compatible. This allows for flexible data storage solutions. ```javascript const Keyv = require('keyv'); const myAdapter = require('./my-storage-adapter'); const keyv = new Keyv({ store: myAdapter }); ``` -------------------------------- ### Get Detailed Axios Error Information with toJSON Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Illustrates how to use the `toJSON` method on an Axios error object to obtain a more comprehensive object containing detailed information about the HTTP error. ```javascript axios.get("/user/12345").catch(function (error) { console.log(error.toJSON()); }); ``` -------------------------------- ### Instantiate Pool with URL and Options Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/undici/docs/docs/api/Pool.md Demonstrates how to create a new Pool instance, specifying the target URL and optional configuration. The URL should include protocol, hostname, and port. Options can customize connection behavior and add interceptors. ```javascript const { Pool } = require('undici'); // Example with URL string and minimal options const pool1 = new Pool('https://example.com'); // Example with URL object and custom options const url = new URL('http://localhost:8080'); const pool2 = new Pool(url, { connections: 10, interceptors: { Pool: [ // Add interceptor logic here ] } }); ``` -------------------------------- ### Handling Axios Responses with `then` (JavaScript) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Demonstrates how to asynchronously handle a successful Axios GET request using `async/await` and the `then` block. It shows how to access various properties of the response object, such as data and status. ```javascript const response = await axios.get("/user/12345"); console.log(response.data); console.log(response.status); console.log(response.statusText); console.log(response.headers); console.log(response.config); ``` -------------------------------- ### Usage Example: Creating and Using a File Cache Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/file-entry-cache/README.md Demonstrates how to create a file cache, retrieve updated files, reconcile cache changes, and handle file entries. It covers loading an existing cache or creating a new one, identifying modified files, persisting cache updates, and managing individual file entries. ```javascript // loads the cache, if one does not exists for the given // Id a new one will be prepared to be created var fileEntryCache = require('file-entry-cache'); var cache = fileEntryCache.create('testCache'); var files = expand('../fixtures/*.txt'); // the first time this method is called, will return all the files var oFiles = cache.getUpdatedFiles(files); // this will persist this to disk checking each file stats and // updating the meta attributes `size` and `mtime`. // custom fields could also be added to the meta object and will be persisted // in order to retrieve them later cache.reconcile(); // use this if you want the non visited file entries to be kept in the cache // for more than one execution // // cache.reconcile( true /* noPrune */) // on a second run var cache2 = fileEntryCache.create('testCache'); // will return now only the files that were modified or none // if no files were modified previous to the execution of this function var oFiles = cache.getUpdatedFiles(files); // if you want to prevent a file from being considered non modified // something useful if a file failed some sort of validation // you can then remove the entry from the cache doing cache.removeEntry('path/to/file'); // path to file should be the same path of the file received on `getUpdatedFiles` // that will effectively make the file to appear again as modified until the validation is passed. In that // case you should not remove it from the cache // if you need all the files, so you can determine what to do with the changed ones // you can call var oFiles = cache.normalizeEntries(files); // oFiles will be an array of objects like the following entry = { key: 'some/name/file', the path to the file changed: true, // if the file was changed since previous run meta: { size: 3242, // the size of the file mtime: 231231231, // the modification time of the file data: {} // some extra field stored for this file (useful to save the result of a transformation on the file } } ``` -------------------------------- ### Consuming a Module with Keyv Cache Support Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Demonstrates how to instantiate a module that supports Keyv caching, showing default in-memory caching and options for using a connection string or a third-party store. ```javascript const AwesomeModule = require('awesome-module'); // Caches stuff in memory by default const awesomeModule = new AwesomeModule(); // After npm install --save keyv-redis const awesomeModule = new AwesomeModule({ cache: 'redis://localhost' }); // Some third-party module that implements the Map API const awesomeModule = new AwesomeModule({ cache: some3rdPartyStore }); ``` -------------------------------- ### JavaScript Request Configuration Object Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Defines the structure of a request configuration object in JavaScript. It includes properties for URL, method, baseURL, headers, data, and more. The `url` is mandatory, and the `method` defaults to 'GET'. ```javascript { // `url` is the server URL that will be used for the request url: '/user', // `method` is the request method to be used when making the request method: 'get', // default // `baseURL` will be prepended to `url` unless `url` is absolute and the option `allowAbsoluteUrls` is set to true. // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs // to the methods of that instance. baseURL: 'https://some-domain.com/api/', // `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`. // When set to true (default), absolute values for `url` will override `baseUrl`. // When set to false, absolute values for `url` will always be prepended by `baseUrl`. allowAbsoluteUrls: true, // `transformRequest` allows changes to the request data before it is sent to the server // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE' // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, // FormData or Stream // You may modify the headers object. transformRequest: [function (data, headers) { // Do whatever you want to transform the data return data; }], // `transformResponse` allows changes to the response data to be made before // it is passed to then/catch transformResponse: [function (data) { // Do whatever you want to transform the data return data; }], // `headers` are custom headers to be sent headers: {'X-Requested-With': 'XMLHttpRequest'}, // `params` are the URL parameters to be sent with the request // Must be a plain object or a URLSearchParams object params: { ID: 12345 }, // `paramsSerializer` is an optional config that allows you to customize serializing `params`. paramsSerializer: { // Custom encoder function which sends key/value pairs in an iterative fashion. encode?: (param: string): string => { /* Do custom operations here and return transformed string */ }, // Custom serializer function for the entire parameter. Allows the user to mimic pre 1.x behaviour. serialize?: (params: Record, options?: ParamsSerializerOptions ), // Configuration for formatting array indexes in the params. indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes). }, // `data` is the data to be sent as the request body // Only applicable for request methods 'PUT', 'POST', 'DELETE', and 'PATCH' // When no `transformRequest` is set, it must be of one of the following types: // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams // - Browser only: FormData, File, Blob // - Node only: Stream, Buffer, FormData (form-data package) data: { firstName: 'Fred' }, // syntax alternative to send data into the body // method post // only the value is sent, not the key data: 'Country=Brasil&City=Belo Horizonte', // `timeout` specifies the number of milliseconds before the request times out. // If the request takes longer than `timeout`, the request will be aborted. timeout: 1000, // default is `0` (no timeout) // `withCredentials` indicates whether or not cross-site Access-Control requests // should be made using credentials withCredentials: false, // default // `adapter` allows custom handling of requests which makes testing easier. // Return a promise and supply a valid response (see lib/adapters/README.md) adapter: function (config) { /* ... */ }, // Also, you can set the name of the built-in adapter, or provide an array with their names // to choose the first available in the environment adapter: 'xhr', // 'fetch' | 'http' | ['xhr', 'http', 'fetch'] // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. // This will set an `Authorization` header, overwriting any existing // `Authorization` custom headers you have set using `headers`. // Please note that only HTTP Basic auth is configurable through this parameter. // For Bearer tokens and such, use `Authorization` custom headers instead. auth: { username: 'janedoe', password: 's00pers3cret' }, // `responseType` indicates the type of data that the server will respond with // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' // browser only: 'blob' responseType: 'json', // default // `responseEncoding` indicates encoding to use for decoding responses (Node.js only) // Note: Ignored for `responseType` of 'stream' or client-side requests // options are: 'ascii', 'ASCII', 'ansi', 'ANSI', 'binary', 'BINARY', 'base64', 'BASE64', 'base64url', } ``` -------------------------------- ### Set Download/Upload Rate Limits (Node.js) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Sets download and upload rate limits for the http adapter in Node.js environments. This example demonstrates setting a 100KB/s upload limit and logging progress and rate. ```javascript const { data } = await axios.post(LOCAL_SERVER_URL, myBuffer, { onUploadProgress: ({ progress, rate }) => { console.log( `Upload [${(progress * 100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`, ); }, maxRate: [100 * 1024], // 100KB/s limit }); ``` -------------------------------- ### Using QuickLRU as a Keyv Storage Adapter Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/keyv/README.md Illustrates integrating the 'quick-lru' module, which implements the Map API, as a Keyv storage adapter for efficient Least Recently Used caching. ```javascript const Keyv = require('keyv'); const QuickLRU = require('quick-lru'); const lru = new QuickLRU({ maxSize: 1000 }); const keyv = new Keyv({ store: lru }); ``` -------------------------------- ### Install ESLint Plugin Kit Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/@eslint/plugin-kit/README.md Instructions for installing the @eslint/plugin-kit package using various package managers for Node.js and Deno. ```shell npm install @eslint/plugin-kit # or yarn add @eslint/plugin-kit # or pnpm install @eslint/plugin-kit # or bun add @eslint/plugin-kit ``` ```shell deno add @eslint/plugin-kit ``` -------------------------------- ### Automatic FormData Serialization with Buffer (Node.js) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/axios/README.md Demonstrates automatic FormData serialization in Node.js, including the handling of Buffer objects within the payload. This example shows how Axios processes complex data types when 'Content-Type' is 'multipart/form-data'. ```javascript const axios = require("axios"); var FormData = require("form-data"); axios .post( "https://httpbin.org/post", { x: 1, buf: Buffer.alloc(10) }, { headers: { "Content-Type": "multipart/form-data", }, }, ) .then(({ data }) => console.log(data)); ``` -------------------------------- ### AMD Loader Installation for Neo-Async Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/neo-async/README.md This example demonstrates how to load Neo-Async using an AMD (Asynchronous Module Definition) loader like RequireJS. It shows the basic syntax for defining a module dependency. ```javascript require(['async'], function(async) {}); ``` -------------------------------- ### Running Tests and Building Docs (Shell) Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/picomatch/README.md Provides shell commands for installing dependencies and running tests, as well as commands for installing global packages and building project documentation using 'verb'. These commands are essential for contributing to the project or understanding its development workflow. ```shell npm install && npm test ``` ```shell npm install -g verbose/verb#dev verb-generate-readme && verb ``` -------------------------------- ### Setup Intro and Outro with Clack Prompts Source: https://github.com/fasuizu-br/n8n-nodes-brainiall/blob/main/node_modules/@clack/prompts/README.md Demonstrates how to use the `intro` and `outro` functions from @clack/prompts to display messages at the beginning and end of a prompt session. These functions are essential for framing the user interaction in a CLI application. ```javascript import { intro, outro } from '@clack/prompts'; intro(`create-my-app`); // Do stuff outro(`You're all set!`); ```