-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sample function for deno runtime (#27)
* feat: added simple typescript sample Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> * doc: updated documentation Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> * feat: added DATA environment variable Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> * feat: added DATA environment variable Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> * feat: added slack function Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> * feat: added slack function Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com> Signed-off-by: Thomas Schuetz <thomas.schuetz@dynatrace.com>
- Loading branch information
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
set -eu | ||
|
||
deno run --allow-net $SCRIPT | ||
deno run --allow-net --allow-env=DATA,SECURE_DATA "$SCRIPT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
let message: string = 'Hello, World!'; | ||
console.log(message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let text = Deno.env.get("DATA"); | ||
let data; | ||
if (text != "") { | ||
data = JSON.parse(text); | ||
} | ||
|
||
let targetDate = new Date(data.targetDate) | ||
let dateTime = new Date(); | ||
|
||
if(targetDate < dateTime){ | ||
console.log("Date has passed - ok"); | ||
Deno.exit(0); | ||
} else { | ||
console.log("It's too early - failing"); | ||
Deno.exit(1); | ||
} | ||
|
||
console.log(targetDate); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
let text = Deno.env.get("SECURE_DATA"); | ||
let data; | ||
if (text != undefined) { | ||
data = JSON.parse(text); | ||
} | ||
|
||
const body = `{"text": "${data.text}"}`; | ||
|
||
console.log(body) | ||
let resp = await fetch("https://hooks.slack.com/services/" + data.slack_hook, { | ||
method: "POST", | ||
body, | ||
}); | ||
|
||
console.log(resp) |