1import { honoHead } from "https://esm.town/v/andreterron/honoHead";
2
3export async function honoGameTest(req: Request) {
4 const { Hono } = await import("npm:hono");
5 const { html } = await import("npm:hono/html");
1export function myApi(name) {
2 return "hi " + name;
3}
1/*
2Currently, `parseXML` is a val.town builtin function, which comes from the fast-xml-parser npm
3package.
4By default, fast-xml-parser does not return tag attributes - you need to instantiate your own
7This constructor does not seem to be exposed in val.town currently.
8
9This function returns a list of audio file urls, in the order they appear in the feed.
10Usually it is safe to assume that the first url is associated with the first episode (by feed
11order), but this is not guaranteed.
12*/
13export function getPodcastAudioUrls(rawXmlText: string): string[] {
14 const enclosureRegex = /<enclosure\s.*url=['"]([^\s]+)['"].*\/>/gm;
15 return [...rawXmlText.matchAll(enclosureRegex)].map((grp) => grp[1]);
1export function debug<T>(value: T, message?: string): T {
2 message ? console.log(message, value) : console.log(value);
3 return value;
1// View at https://prindom-expresshtmlexample.express.val.run/?name=Dominik
2export async function expressHTMLExample(
3 req: express.Request,
4 res: express.Response,
2import { valToString } from "https://esm.town/v/sdan/valToString";
3
4export async function extractValArgs(val: string) {
5 const code = await valToString(val);
6 return extractArgs(code) as Promise<{
2import { email } from "https://esm.town/v/std/email?v=9";
3
4export async function handleFormExample(req, res) {
5 await email({
6 text: JSON.stringify(req.query, null, 2),
1export function nakedAPIEx(req, res) {
2 res.send("my returned srting");
3}
2import { API_URL } from "https://esm.town/v/std/API_URL";
3
4export function runVal(name, ...args) {
5 return fetch(`${API_URL}/v1/run/${name.replace("@", "")}`, {
6 method: "POST",
1export function formatFeedDate(dateString: string): string {
2 const options: Intl.DateTimeFormatOptions = {
3 year: "numeric",
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": "*",