Codetje/WeatherUpdate
v3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
To schedule this function as a cronjob
export a value called "cron"

This function is scheduled every day at 06:00 AM
*/
export const cron = "0 6 * * *"

export default async function WeatherUpdate() {
const apiKey = Deno.env.get("OPEN_WEATHER_MAP_API_KEY")
const response = await fetch("https://api.openweathermap.org/data/2.5/weather?q=Amsterdam,NL&units=metric&appid=" + apiKey)
return await response.json()
}
+
Codetje/ComposeEmail
v2
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
export default async function ComposeEmail(data) {
const apiKey = Deno.env.get("GEMINI_API_KEY")
const prompt = {
"contents": [
{
"role": "user",
"parts": [
{
"text": "Compose an email that will be sent to me containing a summary of the following data. Make sure the email contains no placeholders. \n\n" + JSON.stringify(data)
}
]
}
],
"generationConfig": {
"temperature": 1,
"topK": 40,
"topP": 0.95,
"maxOutputTokens": 8192,
"responseMimeType": "application/json",
"responseSchema": {
"type": "object",
"properties": {
"subject": {
"type": "string"
},
"text": {
"type": "string"
},
"html": {
"type": "string"
}
}
}
}
}
const response = await fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=" + apiKey, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(prompt)
})
const answer = await response.json()
return JSON.parse(answer.candidates[0].content.parts.map((p) => p.text).join("\n"))
}
+
Codetje/Log
v3
1
2
3
4
export default function Log(data) {
console.log(data)
}
+
Codetje/MailMe
v3
1
2
3
4
5
6
7
import { sendMail } from "codetje/mail.ts"

export default async function MailMe(data) {
// This will send an email to the email address you registered with.
await sendMail(data)
}
+
Codetje/YeQuote
v4
1
2
3
4
5
6
7
8
9
10
11
/**
* Functions are executed in an isolated Deno process and
* can import packages like any Deno application would be able to
*/

import { randomYeQuote } from "jsr:@difronzo/random-ye-quote@1";

export default function YeQuote() {
console.log(randomYeQuote());
}
+
Codetje/HelloWorld
v10
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
/**
* Codetje.com is an infinite canvas for
* serverless JavaScript/TypeScript functions.
*/

export default function HelloWorld() {
console.log("Hello world, today's quote is: ")
}

/**
* Functions can be chained together to create workflows
* |
* v
*/











+
OUTPUT
x
...

Sign up to start editing

* responses from executions on this page are cached