1// a very slow and sleepy function
2// pass it ?sleep=33 to make it sleep for that amount of sleep
3export default async function (req: Request): Promise<Response> {
4 const url = new URL(req.url);
5 const sleepQueryParam = url.searchParams.get('sleep');
1export default async function(req: Request): Promise<Response> {
2 console.log(req.url);
3 if (req.headers.get("x-fd-healthprobe") == "1") {
18}
19
20async function BlobPreset<Data>(key: string, initialData: Data) {
21 const db = new Low(new Blob<Data>(key), initialData);
22 await db.read();
1This val provides a way of readily having lots of different Slack bots that do different things and support different Slack workspaces without needing a bunch of Val Town accounts. If you only need a single bot on a single workspace, just go with the approach in the Val Town [docs](https://docs.val.town/integrations/slack/bot/).
2
3This bot is essentially the one described in the Val Town [docs](https://docs.val.town/integrations/slack/bot/), but without any of the details. Those are externalized by the SlackConfig and SlackFunction interfaces. It is just glue. In order to make it work, you will need the following additional glue:
4- a public HTTP val to handle requests like [this one](https://www.val.town/v/curtcox/Chatio)
5- a private val to supply any info missing from the public one like [this one](https://www.val.town/v/curtcox/_not_actually_private_so_that_you_can_see_it)
3import process from "node:process";
4
5export async function sailingNotifyCron({ lastRunAt }) {
6 const result = await sailingNotify("Fair Oaks, CA", 10);
7}
1import { getWeather } from "https://esm.town/v/chet/getWeather";
2import { email } from "https://esm.town/v/std/email";
3export async function sailingNotify(
4 where: string,
5 minWindMph = 1,
1import { blob } from "https://esm.town/v/std/blob";
2import { set } from "https://esm.town/v/std/set?v=11";
3export default async function(req: Request): Promise<Response> {
4 const searchParams = new URL(req.url).searchParams;
5 let value = searchParams.get("todo");
2import { createJTW, getForecast } from "npm:apple-weatherkit";
3
4export async function getAppleWeather(args: { lat: number; lng: number }) {
5 const token = createJTW({
6 teamId: process.env.APPLE_WEATHERKIT_TEAM_ID,
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,
11)`);
12
13async function addTask(description: string) {
14 await sqlite.execute({
15 sql: `INSERT INTO tasks (description) VALUES (?)`,
18}
19
20async function getTasks() {
21 const { columns, rows } = await sqlite.execute(`SELECT id, description, completed FROM tasks`);
22 return rows.map((row) => {
33}
34
35async function toggleTaskCompletion(id: number, completed: boolean) {
36 await sqlite.execute({
37 sql: `UPDATE tasks SET completed = ? WHERE id = ?`,
40}
41
42async function removeTask(id: number) {
43 await sqlite.execute({
44 sql: `DELETE FROM tasks WHERE id = ?`,
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.