Search
api
@ayrtonlacerda
An interactive, runnable TypeScript val by ayrtonlacerda
HTTP
export const api = async (req: Request) => {
const { Hono } = await import("npm:hono");
const app = new Hono();
app.get("/", (c) =>
c.json({
ok: true,
message: "Hello Hono!",
app.post("/", (c) =>
c.json({
ok: true,
lit_example
@pomdtr
Component source: @pomdtr/lit_example_component
HTTP
Component source: @pomdtr/lit_example_component
const html = `
<script type="module" src="https://esm.town/v/pomdtr/lit_example_component"></script>
<simple-greeting name="pomdtr"></simple-greeting>
export default function(req: Request) {
return new Response(html, {
headers: {
"Content-Type": "text/html",
site
@theverything
An interactive, runnable TypeScript val by theverything
Script
import { homePage } from "https://esm.town/v/theverything/homePage";
export let site = (async () => {
return homePage;
valle_tmp_894670518914825972540524579786
@janpaul123
// This val responds to HTTP requests with "Hello, world!"
HTTP
// This val responds to HTTP requests with "Hello, world!"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, world!", { headers: { "Content-Type": "text/plain" } });
streamDemo
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
export default () => {
let timer: number | undefined = undefined;
const body = new ReadableStream({
start(controller) {
timer = setInterval(() => {
const message = `It is ${new Date().toISOString()}\n`;
controller.enqueue(new TextEncoder().encode(message));
}, 1000);
cancel() {
if (timer !== undefined) {
val_4y4XKYYOAg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_4y4XKYYOAg(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Let's explore the logistic map and its transition from order to chaos
// This demonstrates how simple mathematical rules can create complex behavior
function generateLogisticMap(r, iterations, skipFirst) {
let x = 0.5; // Initial population
let results = [];
// Run the logistic map: x = rx(1-x)
consoleEmailEx
@jaydenireland
// email yourself as easily as logging to the console
Script
// email yourself as easily as logging to the console
export let consoleEmailEx = (() => {
console.email("message"); // any JSON object can be the message
console.email({ html: "<h1>hello html emails!</h1>" }); // you can send HTML emails
console.email({ hi: "there" }, "Subject Line"); // optional second arg is the subject line
console.email({ html: "<b>hi!</b>", subject: "Subject accepted here too" });
refs
@jrmann100
An interactive, runnable TypeScript val by jrmann100
Script
export const refs = (): ValRef[] => {
return new Error().stack
.split("\n")
.map((line): ValRef | undefined => {
const groups = new URLPattern({
pathname: "/:vis(v|p)/:userHandle/:valName",
}).exec(line.match(/https?:\/\/[^\s\)]+/)?.at(0) ?? "")?.pathname?.groups;
if (groups === undefined) {
return undefined;
const { userHandle, valName, vis } = groups;
static
@philz
// Sanitize title to create a URL-friendly identifier
HTTP
const app = new Hono();
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
const SCHEMA_VERSION = 5; // Increment this when making schema changes
const ADMIN_TOKEN = Deno.env.get('ADMIN_TOKEN') || 'default_insecure_token';
// Sanitize title to create a URL-friendly identifier
function sanitizeTitle(title: string): string {
return title
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '');
handler
@tempdev
An interactive, runnable TypeScript val by tempdev
Script
// HTML renderer
primewireApiKey,
primewireBase,
} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
interface Meta {
current_quality: string;
id: string;
imdb_id: string;
title: string;
tvdb_id?: null | string;
valle_tmp_995925833637146645728378117787845
@janpaul123
// This val simply responds with "Hello world" on every HTTP request
HTTP
// This val simply responds with "Hello world" on every HTTP request
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world");
graphQLYoga
@dthyresson
GraphQL Yoga Server GraphQL Yoga from The Guild is a batteries-included cross-platform GraphQL over HTTP spec-compliant GraphQL server
powered by Envelop
and GraphQL Tools focused on easy setup, performance and great developer experience. Usage To access GraphiQL - the GraphQL Playground - visit the / route.
That's what you see in the preview pane below. Configuration and Documentation See the GraphQL Yoga documentation for configuration and all the bells and whistles. Endpoint For this example, we'll set to / to make it easier to demo. However, by default, the GraphQL route is configured to be on /graphql which is more common. const yoga = createYoga({
schema,
}) You can set a custom endpoint: const yoga = createYoga({
schema,
graphqlEndpoint: "/my-gql",
}) Landing Page A landing page is shown be default whenever a 404 is hit. You can disable it via the landingPage option. const yoga = createYoga({
schema,
landingPage: false
})
HTTP
# GraphQL Yoga Server
[GraphQL Yoga](https://the-guild.dev/graphql/yoga-server) from [The Guild](https://the-guild.dev) is a batteries-included [cross-platform GraphQL over HTTP spec-compliant GraphQL server](https://github.com/graphql/graphql-http/tree/main/implementations/graphql-yoga)
powered by [Envelop](https://the-guild.dev/graphql/envelop)
and [GraphQL Tools](https://the-guild.dev/graphql/tools) focused on easy setup, performance and great developer experience.
## Usage
To access [GraphiQL](https://the-guild.dev/graphql/yoga-server/docs/features/graphiql) - the GraphQL Playground - visit the `/` route.
const typeDefs = /* GraphQL */ `
type Query {
hello: String
now: String
kyselyVtTypes
@easrng
Kysely type generator for @std/sqlite Usage Fork to your account. Update allowedTables to expose any tables you'd like to import the schema of. This will make their schemas public! Add import type { DB } from "https://yourusername-kyselyVtTypes.web.val.run/?tables=tables,you,need" to your program.
See that QueryParams` type at the top? Add those to your URL to set more options. Demo See @easrng/kyselyVtDemo.
HTTP
# Kysely type generator for @std/sqlite
## Usage
- Fork to your account.
- Update allowedTables to expose any tables you'd like to import the schema of.
**This will make their schemas public!**
- Add `import type { DB } from "https://yourusername-kyselyVtTypes.web.val.run/?tables=tables,you,need" to your program.
type QueryParams = {
camelCase?: "true" | "false";
excludePattern?: string;
includePattern?: string;
scalingDevtoolsValTown2
@jack
An interactive, runnable TypeScript val by jack
HTTP
export let scalingDevtoolsValTown2 = (req: Request) => {
const format = new URL(req.url).searchParams.get("format");
if (!format) {
return Response.json({
"message": "Please provide a 'format' parameter e.g. 'video'",
if (format === "video") {
return Response.redirect(
"https://youtu.be/tUXXANGzE1I?si=DNAWyBwACWEnc9Al",
else {
return Response.redirect(
valle_tmp_393084135551327933207099179023125
@janpaul123
// This approach uses the Hono framework to set up routes for handling comments.
HTTP
// This approach uses the Hono framework to set up routes for handling comments.
// We will store comments in an SQLite database using the `std/sqlite` module for persistence.
// The main route serves the HTML form and displays the comments.
// The POST route handles new comment submissions.
// Create a table for storing comments if it does not exist
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS comments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
comment TEXT NOT NULL,