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

export default {
key: "ntfy-send-notification",
name: "Send Notification",
description: "Send a notification using Ntfy. [See the documentation](https://docs.ntfy.sh/publish/).",
version: "0.0.1",
type: "action",
props: {
app,
topic: {
type: "string",
label: "Topic",
description: "The topic to which the notification will be sent",
},
data: {
type: "string",
label: "Message",
description: "The message content of the notification",
},
headers: {
type: "object",
label: "Headers",
description: "Optional headers to include in the request. [See the documentation](https://docs.ntfy.sh/publish/).",
optional: true,
},
},
methods: {
sendNotification({
topic, ...args
} = {}) {
return this.app.post({
path: `/${topic}`,
...args,
});
},
},
async run({ $ }) {
const {
sendNotification,
topic,
data,
headers,
} = this;

const response = await sendNotification({
$,
headers,
topic,
data,
});

$.export("$summary", `Successfully sent notification with ID \`${response.id}\`.`);
return response;
},
};
24 changes: 19 additions & 5 deletions components/ntfy/ntfy.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "ntfy",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${this.$auth.server}${path}`;
},
_makeRequest({
$ = this, path, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/ntfy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ntfy",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream ntfy Components",
"main": "ntfy.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

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

Loading