Skip to content

Commit 619f7d5

Browse files
committed
Reverting serveravatar
1 parent 0305836 commit 619f7d5

File tree

5 files changed

+98
-13
lines changed

5 files changed

+98
-13
lines changed

components/serveravatar/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.js
2+
*.mjs
3+
dist
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { defineApp } from "@pipedream/types";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default defineApp({
5+
type: "app",
6+
app: "serveravatar",
7+
propDefinitions: {},
8+
methods: {
9+
_getBaseUrl() {
10+
return "https://api.serveravatar.com";
11+
},
12+
_getHeaders() {
13+
return {
14+
"content-type": "application/json",
15+
"authorization": `${this.$auth.api_key}`,
16+
};
17+
},
18+
_getRequestParams(opts: any) {
19+
return {
20+
...opts,
21+
url: this._getBaseUrl() + opts.path,
22+
headers: this._getHeaders(),
23+
};
24+
},
25+
async createApplicationDomain(ctx = this, newAppDomainData: any) {
26+
return await axios(ctx, this._getRequestParams({
27+
method: "POST",
28+
path: "/domains",
29+
data: newAppDomainData,
30+
}));
31+
},
32+
async listTeams() {
33+
const teamsResponse = await axios(this, this._getRequestParams({
34+
method: "GET",
35+
path: "/teams",
36+
}));
37+
return teamsResponse.teams;
38+
},
39+
async listServers(teams: any[]) {
40+
const teamServersPromise = teams.map((team: any) => {
41+
return axios(this, this._getRequestParams({
42+
method: "GET",
43+
path: `/teams/${team.id}/servers`,
44+
}));
45+
});
46+
const teamsServers = await Promise.all(teamServersPromise);
47+
return teamsServers
48+
.map((teamServers: any) => (teamServers.servers))
49+
.flat()
50+
.filter((server: any) => server.status === "1");
51+
},
52+
async listAllServersOptions() {
53+
const teams = await this.listTeams();
54+
const servers = await this.listServers(teams);
55+
return servers.map((server: any) => ({
56+
label: `${server.name} - ${server.ip}`,
57+
value: server.id,
58+
}));
59+
},
60+
async listApplications(serverId: number, page: number) {
61+
const serverApplications = await axios(this, this._getRequestParams({
62+
method: "GET",
63+
path: `/servers/${serverId}/applications?page=${page}`,
64+
}));
65+
return serverApplications?.applications;
66+
},
67+
async listApplicationsOptions(serverId: number, prevContext: any) {
68+
if (!serverId) {
69+
return [];
70+
}
71+
const page = prevContext.page
72+
? prevContext.page + 1
73+
: 1;
74+
const applications = await this.listApplications(serverId, page);
75+
const options = applications.data.map((application: any) => ({
76+
label: `${application.name} - ${application.framework}`,
77+
value: application.id,
78+
}));
79+
return {
80+
options,
81+
context: {
82+
page: applications.current_page,
83+
},
84+
};
85+
},
86+
},
87+
});

components/serveravatar/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@pipedream/serveravatar",
3-
"version": "0.0.5",
3+
"version": "0.0.4",
44
"description": "Pipedream Server Avatar Components",
5-
"main": "serveravatar.app.mjs",
5+
"main": "dist/app/serveravatar.app.mjs",
66
"types": "dist/app/serveravatar.app.d.ts",
7+
"files": [
8+
"dist"
9+
],
710
"keywords": [
811
"pipedream",
912
"serveravatar"

components/serveravatar/serveravatar.app.mjs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.components.json"
3+
}

0 commit comments

Comments
 (0)