Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions components/emaillistverify/actions/find-email/find-email.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../emaillistverify.app.mjs";

export default {
key: "emaillistverify-find-email",
name: "Find Email",
description: "Generate a series of potential email addresses by synthesizing first names, last names, and company domains. [See the documentation](https://emaillistverify.com/docs/#tag/Email-Validation-API/operation/find-contact)",
version: "0.0.1",
type: "action",
props: {
app,
firstName: {
propDefinition: [
app,
"firstName",
],
},
lastName: {
propDefinition: [
app,
"lastName",
],
},
domain: {
propDefinition: [
app,
"domain",
],
},
},
async run({ $ }) {
const response = await this.app.findEmail({
$,
data: {
first_name: this.firstName,
last_name: this.lastName,
domain: this.domain,
},
});

$.export("$summary", `Successfully generated ${response.length} email addresses`);

return response;
},
Comment on lines +30 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Consider adding error handling.

The run method is well-structured and follows best practices for async operations. The use of destructuring for $ and the summary export are good for clarity and user feedback.

Consider adding error handling to improve robustness:

 async run({ $ }) {
-  const response = await this.app.findEmail({
-    $,
-    data: {
-      first_name: this.firstName,
-      last_name: this.lastName,
-      domain: this.domain,
-    },
-  });
+  try {
+    const response = await this.app.findEmail({
+      $,
+      data: {
+        first_name: this.firstName,
+        last_name: this.lastName,
+        domain: this.domain,
+      },
+    });
 
-  $.export("$summary", `Successfully generated ${response.length} email addresses`);
+    $.export("$summary", `Successfully generated ${response.length} email addresses`);
 
-  return response;
+    return response;
+  } catch (error) {
+    $.export("$summary", "Failed to generate email addresses");
+    throw error;
+  }
 },

This change will provide better error reporting and ensure that the action fails properly if an error occurs.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async run({ $ }) {
const response = await this.app.findEmail({
$,
data: {
first_name: this.firstName,
last_name: this.lastName,
domain: this.domain,
},
});
$.export("$summary", `Successfully generated ${response.length} email addresses`);
return response;
},
async run({ $ }) {
try {
const response = await this.app.findEmail({
$,
data: {
first_name: this.firstName,
last_name: this.lastName,
domain: this.domain,
},
});
$.export("$summary", `Successfully generated ${response.length} email addresses`);
return response;
} catch (error) {
$.export("$summary", "Failed to generate email addresses");
throw error;
}
},

};
29 changes: 29 additions & 0 deletions components/emaillistverify/actions/verify-email/verify-email.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import app from "../../emaillistverify.app.mjs";

export default {
key: "emaillistverify-verify-email",
name: "Verify Email",
description: "Verify an email. [See the documentation](https://emaillistverify.com/docs/#tag/Email-Validation-API/operation/verifyEmail)",
version: "0.0.1",
type: "action",
props: {
app,
email: {
propDefinition: [
app,
"email",
],
},
},
Comment on lines +9 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props look good. Consider adding email validation.

The props are correctly defined, and using propDefinition for the email prop is a good practice.

Consider adding some basic validation for the email prop to ensure it's in a valid format before sending it to the API. You could use a regular expression or a built-in email validation function if available in your framework. For example:

email: {
  propDefinition: [
    app,
    "email",
  ],
  description: "The email address to verify",
  validate: (value) => {
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    if (!emailRegex.test(value)) {
      throw new Error("Invalid email format");
    }
  },
},

async run({ $ }) {
const response = await this.app.verifyEmail({
params: {
email: this.email,
},
});

$.export("$summary", `Successfully verified the email. Result: '${response}'`);

return response;
},
Comment on lines +18 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run method looks good. Consider adding error handling.

The run method correctly uses the app's verifyEmail method and provides a useful summary export.

Consider adding error handling to gracefully manage potential API failures or network issues. Here's an example of how you could improve the run method:

async run({ $ }) {
  try {
    const response = await this.app.verifyEmail({
      params: {
        email: this.email,
      },
    });

    $.export("$summary", `Successfully verified the email. Result: '${response}'`);
    return response;
  } catch (error) {
    $.export("$summary", `Failed to verify email: ${error.message}`);
    throw error;
  }
},

This change will provide more informative error messages and ensure that the action fails properly when an error occurs.

};
61 changes: 56 additions & 5 deletions components/emaillistverify/emaillistverify.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,62 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "emaillistverify",
propDefinitions: {},
propDefinitions: {
email: {
type: "string",
label: "Email",
description: "Email to be verified",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the contact",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the contact",
},
domain: {
type: "string",
label: "Email domain",
description: "The domain to use for generating email addresses, i.e.: `gmail.com`",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://apps.emaillistverify.com/api";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
...params,
secret: `${this.$auth.api_key}`,
},
});
},
Comment on lines +32 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure API key is not logged

The _makeRequest method looks well-structured. However, there's a potential security concern:

The API key is included in the request parameters, which might be logged by default in some environments. To enhance security, consider:

  1. Using headers instead of query parameters for the API key:
- params: {
-   ...params,
-   secret: `${this.$auth.api_key}`,
- },
+ headers: {
+   ...otherOpts.headers,
+   "Authorization": `Bearer ${this.$auth.api_key}`,
+ },
+ params,
  1. If you must use query parameters, ensure that your logging configuration masks sensitive data like the API key.

These changes will help prevent accidental exposure of the API key in logs or error messages.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
...params,
secret: `${this.$auth.api_key}`,
},
});
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...otherOpts.headers,
"Authorization": `Bearer ${this.$auth.api_key}`,
},
params,
});
},

async verifyEmail(args = {}) {
return this._makeRequest({
path: "/verifyEmail",
...args,
});
},
Comment on lines +48 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add input validation and error handling to verifyEmail method

The verifyEmail method is concise, but it could benefit from some enhancements:

Consider adding input validation and error handling:

async verifyEmail(args = {}) {
  const { email } = args.params || {};
  if (!email) {
    throw new Error("Email is required for verification");
  }
  try {
    return await this._makeRequest({
      path: "/verifyEmail",
      ...args,
    });
  } catch (error) {
    console.error("Error verifying email:", error);
    throw error;
  }
}

This change ensures that an email is provided and handles potential errors, improving the robustness of the method.

async findEmail(args = {}) {
return this._makeRequest({
method: "post",
path: "/find-contact",
...args,
});
Comment on lines +54 to +59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add input validation and error handling to findEmail method

The findEmail method, like verifyEmail, could benefit from input validation and error handling:

Consider enhancing the method as follows:

async findEmail(args = {}) {
  const { firstName, lastName, domain } = args.data || {};
  if (!firstName || !lastName || !domain) {
    throw new Error("First name, last name, and domain are required for finding an email");
  }
  try {
    return await this._makeRequest({
      method: "post",
      path: "/find-contact",
      ...args,
    });
  } catch (error) {
    console.error("Error finding email:", error);
    throw error;
  }
}

This change ensures that all required fields are provided and handles potential errors, improving the method's reliability.

},
},
};
};
7 changes: 5 additions & 2 deletions components/emaillistverify/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/emaillistverify",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream EmailListVerify Components",
"main": "emaillistverify.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
119 changes: 61 additions & 58 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading