11}
12
13function App() {
14 const [expenses, setExpenses] = useState<Expense[]>([]);
15 const [newExpense, setNewExpense] = useState<Expense>({
127}
128
129function client() {
130 createRoot(document.getElementById("root")).render(<App />);
131}
132if (typeof document !== "undefined") { client(); }
133
134export default async function server(request: Request): Promise<Response> {
135 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
136 const KEY = "expenseTracker";
1export default async function server(request: Request): Promise<Response> {
2 const url = new URL(request.url);
3 const path = url.pathname;
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function Calculator() {
6 const [display, setDisplay] = useState("0");
7 const [firstOperand, setFirstOperand] = useState(null);
114}
115
116function client() {
117 createRoot(document.getElementById("root")).render(<Calculator />);
118}
119if (typeof document !== "undefined") { client(); }
120
121export default async function server(request: Request): Promise<Response> {
122 return new Response(
123 `
12import { servePublicFile } from "https://esm.town/v/stevekrouse/utils@179-main/serve-public/index.ts";
13
14export default async function(req: Request): Promise<Response> {
15 const url = new URL(req.url);
16 if (url.pathname === "/") {
13interface TestCase {
14 name: string;
15 function: () => void;
16}
17
18interface TestCaseResult {
19 name: string;
20 function: () => void;
21 passed: boolean;
22 duration: number;
23}
24
25async function runTest(test: TestCase) {
26 let pass, message;
27 let start = performance.now();
28 try {
29 await test.function();
30 pass = true;
31 } catch (e: any) {
40}
41
42function renderBadge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
43 return makeBadge({
44 label: label ?? "Tests",
48}
49
50function Badge({ label, passedCount, testCount }: { label?: string; passedCount: number; testCount: number }) {
51 const svgMarkup = renderBadge({ label, passedCount, testCount });
52 const srcDoc = `<body style="margin: 0"}>${svgMarkup}</body>`;
62}
63
64function renderTestResults(testGroups: TestGroup[], outputs: { [groupName: string]: TestOutput[] }) {
65 const totalPassed = Object.values(outputs).flat().filter((output: TestOutput) => output.pass).length;
66 const totalTests = testGroups.reduce((sum, group) => sum + group.tests.length, 0);
2import { contentType } from "npm:mime-types@2.1.35";
3
4export async function servePublicFile(path: string, metaImportUrl: string): Promise<Response> {
5 const text = await readFile(path, metaImportUrl);
6 const extname = tsToJSExtension(path).split(".").pop() ?? "";
13}
14
15async function readFile(path: string, metaImportUrl: string) {
16 const project = parseProject(metaImportUrl);
17 const esmURL = project.links.module.projectPinned + path.slice(1);
41}
42
43async function fetchText(url: string) {
44 const res = await fetch(url, {
45 headers: {
55}
56
57function tsToJSExtension(path: string) {
58 if (path.endsWith(".ts")) {
59 return path.slice(0, -3) + ".js";
8 {
9 name: "no-op",
10 function: () => {
11 return true;
12 },
14 {
15 name: "passing test",
16 function: () => {
17 expect(1).toBe(1);
18 },
20 {
21 name: "Failing test",
22 function: () => {
23 expect(1).toBe(2);
24 },
31 {
32 name: "passing test 2",
33 function: () => {
34 expect(1).toBe(1);
35 },
1import { servePublicFile } from "./index.ts";
2
3export default async function(req: Request): Promise<Response> {
4 // serve public files at the root
5 const url = new URL(req.url);
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
1export default async function (interval: Interval) {
2
3}
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.