11// const svg = `<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">Grave Wand</text><text x="10" y="40" class="base">Ornate Chestplate</text><text x="10" y="60" class="base">Dragon's Crown of Protection</text><text x="10" y="80" class="base">War Belt</text><text x="10" y="100" class="base">"Fate Sun" Divine Slippers of Power</text><text x="10" y="120" class="base">Silk Gloves</text><text x="10" y="140" class="base">Necklace</text><text x="10" y="160" class="base">Bronze Ring</text></svg>`;
12
13async function fetchAndParseSvgFromJson(account: string) {
14 try {
15 const response = await fetch(`${url}/${account}`);
42};
43
44function parseElementsFromSvg(svgString: string): SvgTextElement[] {
45 const parser = new DOMParser();
46 // deno-dom only supports HTML
60}
61
62export default async function(req: Request): Promise<Response> {
63 const url = new URL(req.url);
64 console.log(url.searchParams);
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
3
4export async function quote_of_the_day() {
5 const [qod] = await fetchJSON(
6 "https://zenquotes.io/api/today",
4delete frameworks[""];
5
6function absolutePath(url: string) {
7 if (url.startsWith("http")) return url;
8 else return `https://classless-css-demo.deno.dev` + url;
13export const randomStyle = `<link rel="stylesheet" href="${randomURL}">`;
14
15export default function(req: Response) {
16 const url = new URL(req.url);
17
10import { randomStyle } from "https://esm.town/v/stevekrouse/classless_css";
11
12export default async function(req: Request): Promise<Response> {
13 return new Response(`<h1>Welcome to Val Town!</h1>${randomStyle}`, {
14 headers: {
7
8// Fetches a random joke.
9async function fetchRandomJoke() {
10 const response = await fetch(
11 "https://official-joke-api.appspot.com/random_joke",
2import { parentCommentChecker } from "https://esm.town/v/willthereader/parentCommentChecker";
3import { replaceHTMLWithTextFormatting } from "https://esm.town/v/willthereader/replaceHtmlWithTextFormatting";
4export function formattingEmailContent(commentsArray) {
5 // console.log(commentsArray);
6 let commentsString = "";
1export function quine() {
2 return `${quine}`;
3}
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export function getMe(): Promise<{ username: string; id: string; profileImageUrl; bio: string }> {
4 return fetchJSON("https://api.val.town/v1/me", {
5 headers: {
49### Linking to the val
50
51These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the `val` argument:
52
53- `modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }})`
1export function myApi(name) {
2 return "hi " + name;
3}
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.