1import { upgradeExpress } from "https://esm.town/v/easrng/upgradeExpress";
2async function inlineUrls(cssString) {
3 const urlRegex = /url\(['"]?(.*?)['"]?\)/g;
4 let result = cssString;
19import esc from "npm:escape-html@1.0.3";
20import { init } from "npm:server-text-width@1.0.2";
21export const button = upgradeExpress(async function button(req) {
22 const { getTextWidth } = init(
23 IBMPlexSansMetrics,
1export const upgradeExpress = (handler: (request: Request) => Response | PromiseLike<Response>) =>
2 function(request: Request | express.Request, response?: express.Response): Response | Promise<Response> {
3 if (request instanceof Request) {
4 const response = handler(request);
3
4## How it works
5`upgradeExpress` wraps a Web handler into a function that works as normal when called by the Web API, and redirects to the Web API when called by the Express API.
6
7## Example
1import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
2
3export async function alias<P extends Params>(params: P): Promise<Result<P>> {
4 const username = params.username;
5 let url = `${API_URL}/v1/alias/${username}`;
1export function add(a, b) {
2 return a + b;
3}
10`;
11
12export default function(req: Request) {
13 return new Response(
14 html,
1import { blob } from "https://esm.town/v/std/blob?v=11";
2
3export default async function(req: Request): Promise<Response> {
4 const count = (await blob.getJSON("blobCounter") ?? 0) + 1;
5 await blob.setJSON("blobCounter", count);
2import type { ResultSet } from "npm:@libsql/client";
3
4async function execute(statement: InStatement): Promise<ResultSet> {
5 const resp = await fetch("https://sqlite-execute.web.val.run", {
6 method: "POST",
4import stripAnsi from "npm:strip-ansi";
5
6export default async function() {
7 const res = await db.execute(
8 "SELECT author_username, COUNT(*) AS val_count FROM vals GROUP BY author_username ORDER BY 2 DESC LIMIT 10",
3import { blob as blobAPI } from "https://esm.town/v/std/blob";
4
5export async function sqliteBlob(options: SqliteBlobOptions = {}) {
6 const schema = sqliteBlobSchema(options);
7 const sqlite = createSqlite();
10}
11
12export async function sqliteBlobSchema(
13 { prefix = undefined, table = Statement`blobs`, blob = blobAPI }: SqliteBlobOptions = {},
14) {
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.