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
53 changes: 53 additions & 0 deletions components/ipstack/actions/ip-lookup/ip-lookup.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import app from "../../ipstack.app.mjs";

export default {
key: "ipstack-ip-lookup",
name: "IP Lookup",
description: "Look up single IPv4 or IPv6 addresses. [See the documentation](https://ipstack.com/documentation#standard)",
version: "0.0.1",
type: "action",
props: {
app,
ip: {
propDefinition: [
app,
"ip",
],
},
hostname: {
propDefinition: [
app,
"hostname",
],
},
security: {
propDefinition: [
app,
"security",
],
},
language: {
propDefinition: [
app,
"language",
],
},
},
async run({ $ }) {
const response = await this.app.ipLookup({
$,
ip: this.ip,
params: {
hostname: this.hostname
? 1
: 0,
security: this.security
? 1
: 0,
language: this.language,
},
});
$.export("$summary", "Successfully retrieved data for the IP " + this.ip);
return response;
},
};
37 changes: 37 additions & 0 deletions components/ipstack/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export default {

LANGUAGE_OPTIONS: [
{
value: "en",
label: "English/US",
},
{
value: "de",
label: "German",
},
{
value: "es",
label: "Spanish",
},
{
value: "fr",
label: "French",
},
{
value: "ja",
label: "Japanese",
},
{
value: "pt-br",
label: "Portugues (Brazil)",
},
{
value: "ru",
label: "Russian",
},
{
value: "zh",
label: "Chinese",
},
],
};
60 changes: 56 additions & 4 deletions components/ipstack/ipstack.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,63 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "ipstack",
propDefinitions: {},
propDefinitions: {
ip: {
type: "string",
label: "IP",
description: "IPv4 or IPv6 address to be looked up",
},
hostname: {
type: "boolean",
label: "Hostname",
description: "If set to `true`, hostname lookup will be included in the API response",
optional: true,
},
security: {
type: "boolean",
label: "Security",
description: "If set to `true`, includes security module in the API response",
optional: true,
},
language: {
type: "string",
label: "Language",
description: "Output language using 2-letter ISO 639-1 format",
optional: true,
options: constants.LANGUAGE_OPTIONS,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.ipstack.com";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
params,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
params: {
access_key: `${this.$auth.access_key}`,
...params,
},
});
},

async ipLookup({
ip, ...args
}) {
return this._makeRequest({
path: `/${ip}`,
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/ipstack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ipstack",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream ipstack Components",
"main": "ipstack.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

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

Loading