1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2export function SparklineSVG({ strokeWidth = 2, data = [], fill = "none", stroke = "black" }) {
3 const padding = 2;
4 const xMargin = 25;
4const thisURL = parseProject(import.meta.url).links.self.latest;
5
6export async function notify(message: string) {
7 await email({ subject: message, text: `Email sent from ${thisURL}` });
8}
9const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
10
11export async function uptimeCheck(url: string, attempt = 1) {
12 let reason: string = "";
13 let status: number | null = null;
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
38 };
39}
40export default async function(request: Request): Promise<Response> {
41 if (request.method !== "POST") {
42 return new Response("Method Not Allowed", { status: 405 });
3
4// ⏱️ Utility to format New York time with EDT/EST
5function getNewYorkTimeWithZone(dateStr: string): string {
6 const dateObj = new Date(dateStr);
7 return new Intl.DateTimeFormat("en-US", {
17
18// 🗓️ Utility to format the date for the scoreboard wrapper
19function getNewYorkDateHeader(dateStr: string): string {
20 const dateObj = new Date(dateStr);
21 return new Intl.DateTimeFormat("en-US", {
81
82 // ⭐ Extract top performer from competitor-level leaders
83 function extractTopPerformer(team: any): string {
84 const teamName = team?.team?.displayName ?? "Unknown";
85 const leaders = team?.leaders ?? [];
1export default async function(req: Request) {
2 try {
3 const apiKey = Deno.env.get("VALTOWN_API_TOKEN");
67}
68
69async function fetchAllVals(apiKey: string): Promise<Val[]> {
70 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
71 headers: {
87}
88
89async function findCpFiles(val: Val, apiKey: string): Promise<CpFile[]> {
90 try {
91 const files = await fetchValFiles(val.id, apiKey);
120}
121
122async function fetchValFiles(valId: string, apiKey: string): Promise<ValFile[]> {
123 const filesResponse = await fetch(
124 `https://api.val.town/v2/vals/${valId}/files?path=&recursive=true&limit=100`,
139}
140
141function filterCpFiles(files: ValFile[]): ValFile[] {
142 const cpPattern = /^cp-/;
143
150}
151
152function constructHttpUrl(val: Val, file: ValFile, fileInfo: any): string {
153 const username = val.author?.username || "unknown";
154
172}
173
174async function checkIfHttpEndpoint(
175 val: Val,
176 file: ValFile,
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
Simple functional CSS library for Val Town
A helper function to build a file's email
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.