Search
val_Wr3Zuo6Ytx
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
val_YwQRbwgDeL
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
getWttr
@LavaC
An interactive, runnable TypeScript val by LavaC
HTTP
export let getWttr = async ({ location }) => {
function convertBlobToDataUrl(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const dataUrl = reader.result;
resolve(dataUrl);
reader.onerror = () => {
reject(reader.error);
reader.readAsDataURL(blob);
axiosTest
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export const axiosTest = (async () => {
const { default: axios } = await import("npm:axios");
const res = await axios.get("https://jsonplaceholder.typicode.com/todos/1");
return res;
main
@Timmy
An interactive, runnable TypeScript val by Timmy
Cron
export async function main() {
let latestIssue = 643;
const init = (async () => {
const currentIssueNumber = await getIssueNumber;
console.log(currentIssueNumber, "--------");
if (currentIssueNumber > latestIssue) {
latestIssue = currentIssueNumber;
await email({
text:
`There is a new issue on JavaScript Weekly: https://javascriptweekly.com/issues ${latestIssue}`,
rssDemo10
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Cron
import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems";
export async function rssDemo10(interval) {
let items = await newRSSItems({
url: inkAndSwitchRssUrl,
lastRunAt: interval.lastRunAt,
if (items?.length)
return email({
text: JSON.stringify(items, null, 2),
subject: "New from Ink & Switch",
get1
@byjonathanleung
An interactive, runnable TypeScript val by byjonathanleung
Script
export let get1 = (x) => {
return "hello world";
yellowYak
@tempguy
// This is an IIFE to allow the use of top-level await in Node.js
Script
// This is an IIFE to allow the use of top-level await in Node.js
(async () => {
try {
const options = {
uri: "https://website.com/",
formData: { field1: "value", field2: 2 },
const response = await cloudscraper.post(options);
console.log(response);
} catch (error) {
console.error(error);
val_KbMWZdfs38
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
vtInspoHTML
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
export function vtInspoHTML(req, res) {
res.send(
valTownInspoList.map((valTownInspo) =>
`<h3>Daily Val Town inspiration</h3>
<h1>${valTownInspo.title}</h1>
<p>${valTownInspo.description}</p>
<a href="https://val.town/${valTownInspo.val}"><img src="https://val.town/v/${valTownInspo.val}.png" style="max-width:576px"/></a>
<p>
</p>`
).join("\n"),
runGET
@rld
// Forked from @stevekrouse.runGET
Script
import { id } from "https://esm.town/v/rld/id";
export let runGET = id(
"This is a GET request to the @rld.runGET endpoint in val.town",
// Forked from @stevekrouse.runGET
proxyFetch10
@alp
An interactive, runnable TypeScript val by alp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const proxyFetch10 = async (req, res) => {
const { url, options } = req.body;
try {
const response = await fetch(url, options);
return res.status(response.status).send(await response.text());
} catch (e) {
const errorMessage = e instanceof Error ? e.message : "Unknown error";
console.error("Failed to initiate fetch", e);
return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
postWebhook1
@kylebutts
An interactive, runnable TypeScript val by kylebutts
Script
export let postWebhook1 = async (req, res) => {
const a = await newRSSItems({
url: "https://elliot.website/editor/feed.rss",
lastRunAt: new Date("Mon, 31 Oct 2021 00:00:00 +0000"),
res.send(`
<h1>My latest RSS</h1>
<ul>${a
.map(
({ title, link, description, pubDate }) => `
<li>
prolificVioletToucan
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
plants
@stevekrouse
Made with val writer With prompt The app is just a simple plant watering app.
Had a bunch of plants with different watering schedules.
I want to be able to add new plants.
I want to open the app and mark a plant as watered.
I want to track all watering events.
Store only a `waterings` table where the plant name is a string.
HTTP
Made with [val writer](https://stevekrouse-valwriter.web.val.run/?description=The+app+is+just+a+simple+plant+watering+app.+Had+a+bunch+of+plants+with+different+watering+schedules.+I+want+to+be+able+to+add+new+plants.+I+want+to+open+the+app+and+mark+a+plant+as+watered.+I+want+to+track+all+watering+events.+Store+only+a+%60waterings%60+table+where+the+plant+name+is+a+string.)
With prompt
The app is just a simple plant watering app.
Had a bunch of plants with different watering schedules.
I want to be able to add new plants.
I want to open the app and mark a plant as watered.
/** @jsxImportSource npm:hono@3/jsx */
// Initialize the SQLite database and create the waterings table
sqlite.execute(`
CREATE TABLE IF NOT EXISTS waterings (