-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathlookup-hosted-domain.mjs
49 lines (48 loc) · 1.3 KB
/
lookup-hosted-domain.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import ip2location from "../../ip2location_io.app.mjs";
export default {
key: "ip2location_io-lookup-hosted-domain",
name: "Lookup Hosted Domain",
description: "Retrieve the list of hosted domains on an IP Address. [See the docs here](https://www.ip2location.io/ip2whois-domains-documentation)",
version: "0.0.1",
type: "action",
props: {
ip2location,
ip: {
type: "string",
label: "IP Address",
description: "IP address (IPv4 or IPv6) to lookup",
},
format: {
propDefinition: [
ip2location,
"format",
],
},
page: {
type: "integer",
label: "Page",
description: "Pagination result returns of the hosted domains. If unspecified, 1st page will be used.",
optional: true,
},
},
async run({ $ }) {
try {
const response = await this.ip2location.lookupHostedDomain({
params: {
ip: this.ip,
format: this.format,
page: this.page,
},
});
if (response && response.total_domains) {
$.export(
"$summary",
`Successfully retrieved hosted domain information about IP ${this.ip}.`,
);
}
return response;
} catch (error) {
throw new Error(`Error retrieving hosted domains: ${error.message}`);
}
},
};