40- Key: `mentionsDiscord`
41- Value: Your Discord webhook URL.
42Notifications will be sent using this function:
43```
44 await discordWebhook({
4import process from "node:process";
5
6export async function hnValTown({ lastRunAt }: Interval) {
7 // Edit to update time frame
8 const twoMonthsAgo = new Date();
3import React, { useCallback, useEffect, useMemo, useRef, useState } from "https://esm.sh/react@18.2.0";
4
5function GameChallenge({ user, onGameEnd }) {
6 const [level, setLevel] = useState(1);
7 const [timeLeft, setTimeLeft] = useState(60);
102}
103
104function App() {
105 const [user, setUser] = useState(null);
106 const [username, setUsername] = useState("");
273}
274
275function client() {
276 createRoot(document.getElementById("root")).render(<App />);
277}
278if (typeof document !== "undefined") { client(); }
279
280export default async function server(request: Request): Promise<Response> {
281 try {
282 // Dynamically import sqlite with error handling
284 try {
285 sqlite = await import("https://esm.town/v/stevekrouse/sqlite");
286 if (!sqlite || !sqlite.sqlite || typeof sqlite.sqlite.execute !== "function") {
287 throw new Error("Invalid SQLite module");
288 }
1export default async function server(request: Request): Promise<Response> {
2 console.log("request", request);
3 try {
86}
87
88function generateICalFeed(events) {
89 const icalLines = [
90 "BEGIN:VCALENDAR",
110}
111
112function formatICalDate(dateString) {
113 if (!dateString) return "";
114 const date = new Date(dateString);
58};
59
60function Table({ data }) {
61 return (
62 <>
72}
73
74export default async function(e: Email) {
75 if (!Deno.env.get("INSTANTDB_ADMIN_TOKEN")) {
76 throw new Error("INSTANTDB_ADMIN_TOKEN not set");
6import { retryFill } from "https://esm.town/v/alexwein/gridRetryFill";
7
8function App({ board, solution }) {
9 return (
10 <div style={{ fontFamily: 'Arial, sans-serif', maxWidth: '800px', margin: '0 auto', padding: '20px' }}>
28}
29
30function client() {
31 createRoot(document.getElementById("root")).render(<App board={window.boardSVG} solution={window.boardSolution} />);
32}
33if (typeof document !== "undefined") { client(); }
34
35export async function fabw() {
36 // Import d3 and Plot with a server-side compatible approach
37 const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
91}
92
93export default async function(request: Request) {
94 const { board, solution } = await fabw();
95
42 - Value: Your SERP API key.
43
44Without this key, the val will not function correctly.
45
46---
58- Key: `mentionsDiscord`
59- Value: Your Discord webhook URL.
60Notifications will be sent using this function:
61```
62 await discordWebhook({
12const isProd = true;
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "Utrecht"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });
7const serpApiKey = Deno.env.get("SERP_API_KEY");
8
9export async function redditAlert({ lastRunAt }: Interval) {
10 if (!serpApiKey || !mentionsDiscord) {
11 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",