Search
ittyExample
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
import { Router, json } from "npm:itty-router@4";
export const ittyRouterExample = async (request: Request) => {
const router = Router();
router.get("/", () => "Hi from itty-router!");
return router.handle(request).then(json);
rule
@cescyang_service
An interactive, runnable TypeScript val by cescyang_service
Script
export function rule(response) {
const requiredApps = [
"55a54008ad1ba589aa210d2629c1df41",
"94b3bfd329374b9fb288f72cfcdcd4da",
"9ddc1d1392af462895f23c9aa7a64de1",
"30055ae3c14f46c38f11df1833a51893",
// "da65c5be95db4c09a68627e81a44d63c", // Scaffolding
"1876cd4464a749dbab0acfd57d797f90",
"15e54d64b8de45b1b869d012ba346c2f",
"6631176c87a24532b1a109205aec5e51",
periodical_weather_telegram
@flafi87
An interactive, runnable TypeScript val by flafi87
Cron
const API_KEY = Deno.env.get("OPENWEATHERMAP_APP_ID");
const LATITUDE = Deno.env.get("LATITUDE");
const LONGITUDE = Deno.env.get("LONGITUDE");
const CHAT_ID = Deno.env.get("TELEGRAM_CHAT_ID");
const TELEGRAM_TOKEN = Deno.env.get("TELEGRAM_TOKEN");
const THINGSPEAK_CHANNEL_ID = Deno.env.get("THINGSPEAK_CHANNEL_ID");
const fetchLatestTemperatureFromThingSpeak = async (channelId = THINGSPEAK_CHANNEL_ID, resultsCount = 1) => {
const baseUrl = "https://api.thingspeak.com/channels";
const url = `${baseUrl}/${channelId}/feeds.json?results=${resultsCount}`;
try {
flydotioRSS
@mstubbs
An interactive, runnable TypeScript val by mstubbs
HTTP
export async function flydotioRSS(req: Request): Promise<Response> {
const response = await fetch("https://fly.io/blog/");
const body = await response.text();
const $ = cheerio.load(body);
const feed = new Feed({
title: "Fly.io Blog",
description: "This is my personal feed!",
id: "https://fly.io/blog/",
link: "https://fly.io/blog/",
image: "https://fly.io/static/images/favicon/favicon-32x32.png",
search_heroicons
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
export default async function(ctx: BrowserContext) {
const resp = await fetch("https://api.iconify.design/collection?prefix=heroicons");
if (!resp.ok) {
throw new Error(await resp.text());
const { uncategorized: icons } = await resp.json() as { uncategorized: string[] };
const items = icons.filter(
(icon) => !icon.endsWith("-solid"),
).map(icon => ({
icon,
title: icon,
unpaywall
@yawnxyz
// Unpaywall DOI access function
HTTP
const app = new Hono();
const YOUR_EMAIL = "jan@phage.directory";
// Unpaywall DOI access function
async function unpaywallDOI(doi) {
const url = `https://api.unpaywall.org/v2/${doi}?email=${YOUR_EMAIL}`;
const options = {
method: 'GET',
headers: {
'accept': 'application/json',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
wasmExample
@just_be
An interactive, runnable TypeScript val by just_be
HTTP
const wabt = await loadWabt();
export default async function(req: Request): Promise<Response> {
return new Response(
wabt.parseWat(
`test.wasm`,
`(module
(func $add (param $lhs i32) (param $rhs i32) (result i32)
local.get $lhs
local.get $rhs
i32.add)
expressTestSimple
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const expressTestSimple = (req, res) => res.send("success!");
pyodideSetup
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
const pyodideUrl = "https://cdn.jsdelivr.net/pyodide/v0.26.4/full/";
export async function initializePyodide() {
// Set up the global objects that Pyodide expects
(globalThis as any).window = globalThis;
(globalThis as any).document = {
location: { href: pyodideUrl },
currentScript: { src: `${pyodideUrl}pyodide.js` }
(globalThis as any).navigator = {
userAgent: 'Mozilla/5.0 (Pyodide)'
// Import Pyodide
webinstruction
@roadlabs
tldraw computer custom endpoint example This val is an example custom endpoint for tldraw computer 's data component. Usage To use this val with tldraw.computer, follow these steps: Fork this Val. Click the Copy endpoint button on your new Val. Open a project on tldraw.computer Create a Data component in your tldraw computer project In the Source dropdown, select Custom and the POST method Paste the endpoint into Data component's the HTTP Endpoint input. Run the component. To see the output, connect the Data component to a Text component. How it works In tldraw computer, you can configure a Data component to use a custom HTTP endpoint as its data source. You can also configure the request method, either GET or POST. If a Data component's request method is POST, then when the component next updates, it will send a POST request to the endpoint. The request's body will contain an array of the Data objects that the component had received as inputs. If the request method if GET, then the component will only make the request—its body will be empty. In both cases, the component will expect back a response that includes an array of Data objects these objects will be passed along as the data component's outputs. The endpoint (your forked version of this Val) can do whatever it likes between the request and response, but the response must include data in the correct format. If the format is wrong, the computer app will create a text data object instead that includes the response as plain text. Support If you're running into any difficulties, check out the #tldraw-computer channel on the tldraw discord.
HTTP
# tldraw computer custom endpoint example
This val is an example custom endpoint for [tldraw computer](tldraw.computer)'s data component.
### Usage
To use this val with tldraw.computer, follow these steps:
1. Fork this Val.
2. Click the **Copy endpoint** button on your new Val.
// This endpoint accepts and returns data.
type BooleanData = {
type: "boolean";
text: "true" | "false" | "maybe";
valle_tmp_9644417173466035944233895282862
@janpaul123
// This val responds with "Hello world" to all incoming requests
HTTP
// This val responds with "Hello world" to all incoming requests
export default async function (req: Request): Promise<Response> {
return new Response("Hello world");
freshBeigeScorpion
@jeffreyyoung
Shows a preview and then says meow for 5 seconds
https://poe.com/preview-then-slow things to note: don't put underscores in the name name, it stops working
HTTP
Shows a preview and then says meow for 5 seconds
https://poe.com/preview-then-slow
things to note:
- don't put underscores in the name name, it stops working
* Returns a response to the user's query
async function getResponse(req: Query, send: SendEventFn) {
send("meta", { content_type: "text/markdown" });
send("text", {
text: `
Here is a preview
competitiveGraySkunk
@jeffreyyoung
Shows a preview and then says meow for 5 seconds
https://poe.com/preview-then-slow things to note: don't put underscores in the name name, it stops working
HTTP
Shows a preview and then says meow for 5 seconds
https://poe.com/preview-then-slow
things to note:
- don't put underscores in the name name, it stops working
* Returns a response to the user's query
async function getResponse(req: Query, send: SendEventFn) {
send("meta", { content_type: "text/markdown" });
let i = 0;
let message = "";
let totalLength = 0;
vtu_deleteUser
@rozek
(documentation follows)
Script
(documentation follows)
import {
expectEMailAddress
} from 'npm:javascript-interface-library'
import { blob } from "https://esm.town/v/std/blob"
export default async function deleteUser (UserId:string):Promise<void> {
expectEMailAddress('user id',UserId)
const normalizedUserId = UserId.toLowerCase().trim()
const UserKey = `vtu_User_${normalizedUserId}`
await blob.delete(UserKey)
diesel
@yawnxyz
Diesel Diesel is a lightweight data manipulation library inspired by Tom Wright's Dasel, designed for easy querying and transformation of various data formats such as JSON, YAML, CSV, and TOML. It allows users to select, update, and delete data using a simple selector syntax. Heavily adapted from https://github.com/TomWright/dasel Features Multi-format Support : Works with JSON, YAML, CSV, and TOML. Dynamic Selectors : Use conditions to filter data dynamically. Function Support : Built-in functions for data manipulation (e.g., length, sum, avg). Easy Integration : Can be used in both Deno and Val Town environments. Usage import Diesel from "https://esm.town/v/yawnxyz/diesel";
async function main() {
const jsonData = `
{
"users": [
{"id": 1, "name": "Alice", "age": 30},
{"id": 2, "name": "Bob", "age": 25},
{"id": 3, "name": "Charlie", "age": 35}
],
"settings": {
"theme": "dark",
"notifications": true
}
}
`;****
const diesel = new Diesel(jsonData, 'json');
try {
console.log("All data:", await diesel.select(''));
console.log("All users:", await diesel.select('users'));
console.log("First user's name:", await diesel.select('users.[0].name'));
console.log("Users over 30:", await diesel.select('users.(age>30)'));
await diesel.put('settings.theme', 'light');
console.log("Updated settings:", await diesel.select('settings'));
// await diesel.delete('users.[1]');
// console.log("Users after deletion:", await diesel.select('users'));
console.log("Data in YAML format:");
console.log(await diesel.convert('yaml'));
console.log("Data in TOML format:");
console.log(await diesel.convert('toml'));
console.log("Number of users:", await diesel.select('users.length()'));
console.log("User names in uppercase:", await diesel.select('users.[*].name.toUpper()'));
} catch (error) {
console.error("An error occurred:", error);
}
}
main(); Installation To use Diesel, simply import it in your Deno project as shown in the usage example. License This project is licensed under the MIT License.
Script
# Diesel
Diesel is a lightweight data manipulation library inspired by Tom Wright's Dasel, designed for easy querying and transformation of various data formats such as JSON, YAML, CSV, and TOML. It allows users to select, update, and delete data using a simple selector syntax.
Heavily adapted from https://github.com/TomWright/dasel
## Features
- **Multi-format Support**: Works with JSON, YAML, CSV, and TOML.
- **Dynamic Selectors**: Use conditions to filter data dynamically.
// import * as jsonMod from "https://deno.land/std@0.224.0/json/mod.ts";
// import * as csv from "npm:csvtojson";
// import { readCSV, readCSVRows, writeCSV } from "jsr:@vslinko/csv";
// import { parse as parseCSV, stringify as stringifyCSV } from "https://deno.land/std/csv/mod.ts";