Search
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
rime
@stevekrouse
// We provide some amount of free usage to this API
Script
// We provide some amount of free usage to this API
// Callable with my API key via api(@stevekrosue.rime, {text: "blah blah", ...})
export async function rime({ text, speaker, key }: {
text: string;
speaker: string;
return "Rime rate limit exceeded";
return fetchJSON(
"https://rjmopratfrdjgmfmaios.functions.supabase.co/rime-tts",
method: "POST",
headers: {
oceanTheremin
@all
An interactive, runnable TypeScript val by all
HTTP
export default async function server(request: Request): Promise<Response> {
const html = `
const status = document.getElementById('status');
function initAudio() {
audioContext = new (window.AudioContext || window.webkitAudioContext)();
gainNode.gain.setValueAtTime(0, audioContext.currentTime);
function togglePlay() {
if (!isPlaying) {
status.textContent = 'Communication stopped. Press Start to begin again.';
function panic() {
if (audioContext) {
status.textContent = 'Emergency stop activated. System reset. Press Start to begin again.';
function updateAudio(event) {
if (!isPlaying) return;
gainNode.gain.setValueAtTime(volume, audioContext.currentTime);
function updateReverb() {
if (reverbNode) {
reverbNode.wet.value = parseFloat(reverbSlider.value);
function updateNoise() {
if (noiseNode) {
valle_tmp_17314117069468577415194390357787
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
export default async function main(req: Request): Promise<Response> {
const styles = `
let currentRow = 0;
function createBoard() {
const board = document.querySelector('.board');
board.appendChild(cell);
function handleInput(event) {
const input = event.target;
fetch_docs
@andreterron
Proxied fetch - https://docs.val.town/std/fetch
Script
import { API_URL } from "https://esm.town/v/std/API_URL";
* Wraps the JavaScript Fetch function to anonymize where the request is
* coming from ([Docs ↗](https://docs.val.town/std/fetch))
* @param {string | URL | Request} input - The resource to fetch.
* @param {RequestInit} [requestInit] - Optional configuration data (HTTP
* method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
const origReq = new Request(input, requestInit);
const url = new URL("/v1/fetch", API_URL);
web_xBDVCIfKtv
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_xBDVCIfKtv(req) {
return new Response(`<!DOCTYPE html>
<html>
mootex
@maxm
HTTP
<code dangerouslySetInnerHTML={{ __html: highlightedCode }} />
</pre>
export default async function(req: Request): Promise<Response> {
const pageContent = renderToString(
<html>
![stevekrouse avatar](https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg)
createVal
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
readme?: string;
privacy?: "public" | "unlisted" | "private";
export function createVal({ token, ...data }: { token?: string } & CreateValArgs): Promise<ValResponse> {
return fetchJSON("https://api.val.town/v1/vals", {
bearer: token || Deno.env.get("valtown"),
![rodrigotello avatar](https://images.clerk.dev/uploaded/img_2Q1sy7hYih37Ssro2ac4uxgyWtH.png)
handleOnboardingServices
@rodrigotello
// Triggered when someone tells us what they want to use VT for
Script
import process from "node:process";
// Triggered when someone tells us what they want to use VT for
export async function handleOnboardingServices({ auth, handle, services }: {
auth: string;
handle: string;
valTownInspoList
@charmaine
Val Town inspiration & use cases list List [as object] used in Val Town's use cases and inspiration.
Check it out at in /examples/use-cases and /docs/tutorial/4
Script
"https://air-prod.imgix.net/11aee64e-8d3d-4f13-9bb0-e1cef14bc74c.jpg?w=1200&h=2000&auto=compress&ixlib=react-9.5.4",
"title": "Generate PDFs",
"description": "Generate PDFs using val functions by using an external library like jsPDF",
"val": "@vtdocs.examplePDF",
image:
![yawnxyz avatar](https://images.clerk.dev/oauth_github/img_2NnaHhpxNuH1xWRIRjQNoo16TVc.jpeg)
duckdbExample
@yawnxyz
DuckDB DuckDB works on Val Town, with only one small tweak! We're basically using DuckDB in the same way you'd use it with a browser - using the WASM package with its dependencies fetched from jsdelivr . The only trick is to create the worker ourselves rather than using duckdb.createWorker . DuckDB's built-in createWorker method doesn't specify a worker type, which causes type to default to classic , and Deno (our runtime) doesn't support classic workers. Note: A small check was added to make this compatible with local Deno. if (typeof Deno !== "undefined") {
return new Worker(url, { type: "module", deno: true });
}
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let duckdbExample = await (async () => {
async function createWorker(url) {
// For Val Town / Deno environments
if (typeof Deno !== "undefined") {
![yawnxyz avatar](https://images.clerk.dev/oauth_github/img_2NnaHhpxNuH1xWRIRjQNoo16TVc.jpeg)
instantDbTest
@yawnxyz
// ID for app: wonderful-wombat
Script
// // Write Data
// function addTodo(text) {
// db.transact([tx.messages[id()].update({ text: 'what' })]);
// // createdAt: Date.now(),
// function deleteTodoItem(message) {
// db.transact(tx.messages[message.id].delete());
// function toggleDone(message) {
// db.transact(tx.messages[message.id].update({ done: !message.done }));
// function deleteCompleted(messages) {
// const completed = messages.filter((message) => message.done);
// db.transact(txs);
// function toggleAllTodos(messages) {
// const newVal = !messages.every((message) => message.done);
// db.transact(messages.map((message) => tx.messages[message.id].update({ done: newVal })));
// function query(q = { messages: {} }) {
// const { isLoading, error, data } = db.subscribeQuery({ messages: {} });
// console.log('data', data);
// function renderError(error) {
// console.error(error);
// function render(data) {
// console.log(data);
empatheticPeachEchidna
@Beligol522
@jsxImportSource https://esm.sh/react
Cron
import { createRoot } from "https://esm.sh/react-dom/client";
function DogClicker() {
const [dogs, setDogs] = useState(0);
</div>
function client() {
createRoot(document.getElementById("root")).render(<DogClicker />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
val_eYhhIv3Mvd
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_eYhhIv3Mvd(req) {
try {
// Execute the code directly and capture its result
![eufracio avatar](https://images.clerk.dev/oauth_github/img_2SkyYy779sdLLsNqNQWofykouOu.jpeg)
myApi
@eufracio
An interactive, runnable TypeScript val by eufracio
Script
export function myApi(name) {
return "hi " + name;
valle_tmp_0028705057670890266002206804567040699
@janpaul123
// This val will respond with "Hello world" to all incoming HTTP requests
HTTP
// This val will respond with "Hello world" to all incoming HTTP requests
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world");