Search

Results include substring matches and semantically similar vals. Learn more
vez avatar
comments
@vez
Comments (just add water) A self-contained comments system Val. Just fork this val and you have a complete (but extremely minimal) comment system! Call on the front-end using: const MY_FORKED_VAL_URL = "https://vez-comments.web.val.run"; const getComments = async () => { const response = await fetch(MY_FORKED_VAL_URL); const json = await response.json(); return json; }; const addComment = async (str) => { try { const response = await fetch(MY_FORKED_VAL_URL, { method: "POST", body: JSON.stringify(str), }); if (response.status >= 400 && response.status < 600) { /* error */ return false; } else { /* success */ return true; } } catch (e) { /* error */ return false; } }; Here's an example of a blog post where I used the val for the comment system: https://vezwork.github.io/polylab/dist/demo/bidirectionalParse/. Check out "view source"!
HTTP
import { Hono } from "npm:hono@3.9.2";
const KEY = import.meta.url.split("?")[0];
export async function addComment(str) {
const comments = await blob.getJSON(KEY) as Array<string> ?? [];
comments.push(str);
await blob.setJSON(KEY, comments);
await email({ text: "New Comment Alert!: " + str });
export async function getComments() {
return await blob.getJSON(KEY) as Array<string> ?? [];
const app = new Hono();
rozek avatar
Authorization_from_EnvVar
@rozek
Some tests can be find in val Authorization_from_EnvVar_Tests
Script
expectStringMatching, allowOneOf, expectInstanceOf
} from 'https://rozek.github.io/javascript-interface-library/dist/javascript-interface-library.esm.js'
export async function RequestIsAuthorized(
ValRequest:Request, EnvVarName:string, Mode?:string
):Promise<boolean> {
cwervo avatar
exampleData
@cwervo
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
Script
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
export async function exampleData(req: express.Request, res: express.Response) {
return res.send(JSON.stringify({ data: [0, 1, 2, 3, 4, 5, 6] }));
// Forked from @stevekrouse.expressHTMLExample
git avatar
rattyAmberLeopard
@git
An interactive, runnable TypeScript val by git
HTTP
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const passedUrl = url.searchParams.get("url");
Timmy avatar
test
@Timmy
An interactive, runnable TypeScript val by Timmy
Script
export const test = (async function init() {
const res = await import("https://esm.sh/web-features/index.json") assert { type: "json" };
return res;
tmcw avatar
devstats
@tmcw
Developer Statistics This val lets you post statistics from your GitHub Actions runs to build charts of change over time. We do this by having a step at the end of our actions run like this: - name: devstats run: | curl -X "POST" "https://tmcw-devstats.web.val.run/" \ -H 'Authorization: Bearer ${{ secrets.DEVSTATS_TOKEN }}' \ -H 'Content-Type: application/json; charset=utf-8' \ -d $"{ \"name\": \"node_modules_kb\", \"value\": $(du -sk node_modules | awk '{print $1}') }" And setting a DEVSTATS_TOKEN value, which could be any short random value, both in Val Town environment variables and as a secret in your GitHub Actions configuration. Currently the name you attach to a statistic can be anything, and the value is expected to be a number.
HTTP
}).toString().split("\n").slice(1).slice(0, -1).join("\n")
async function getRows() {
const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME}`)
type Rows = Awaited<ReturnType<typeof getRows>>
app.get("/api", async function apiRoute(c) {
try {
return c.text("Error inserting data", 500)
export default async function(req: Request): Promise<Response> {
await sqlite.execute(`
browserbase avatar
browserbaseUtils
@browserbase
Utils to loadPageContent() and screenshotPage() . Browserbase Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents. Get started with Browserbase for free here . If you have any questions, reach out to developer@browserbase.com.
Script
export interface LoadPageContentOptions {
textContent: boolean;
export async function loadPageContent(url: string, options: LoadPageContentOptions = { textContent: false }) {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
export interface ScreenshotPageOptions {
fullPage: boolean;
export async function screenshotPage(url: string, options: ScreenshotPageOptions = { fullPage: true }) {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
ajn avatar
dailyDadJoke
@ajn
Daily Dad Joke How do you make a programmer laugh every morning? A dad joke cron job! Setup Fork this val Click Create fork 🤣🤣🤣🤣 API This val uses the icanhazdadjoke API . You can find more docs here , such as how to filter by type .
Cron
import { email } from "https://esm.town/v/std/email";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export async function dailyDadJoke() {
let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
return email({
mohsen avatar
captivatingPurpleTapir
@mohsen
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
function App() {
async function fetchStocks() {
async function fetchOperations() {
async function addStock(e) {
async function deleteStock(symbol: string, shares: number, purchasePrice: number) {
async function updateStock(stock) {
export default async function server(request: Request): Promise<Response> {
// Function to log operations
async function logOperation(type: string, details: string) {
// Existing fetchStockPrice function remains the same
dps avatar
FunctionToHTMLForm
@dps
An interactive, runnable TypeScript val by dps
HTTP
import { valForm } from "https://esm.town/v/rodrigotello/valForm";
import { multiplicationFunctionTest } from "https://esm.town/v/rodrigotello/multiplicationFunctionTest";
export async function FunctionToHTMLForm(
req: express.Request,
res: express.Response,
let myFunctionValAsHTML = multiplicationFunctionTest; // Insert your function here and it should generate an HTML form
return res.send(`${valForm(myFunctionValAsHTML)}`);
acmu avatar
myApiAdd
@acmu
An interactive, runnable TypeScript val by acmu
Script
import { set } from "https://esm.town/v/std/set?v=11";
let { nameList } = await import("https://esm.town/v/acmu/nameList");
export async function myApiAdd(name) {
if (Array.isArray(nameList)) {
nameList.push(name);
loading avatar
xkcd
@loading
An interactive, runnable TypeScript val by loading
HTTP
import { parseFeed } from "jsr:@mikaelporttila/rss@*";
export default async function(req: Request): Promise<Response> {
return new Response(
(await parseFeed(
augustohp avatar
BalanceCapMonster
@augustohp
An interactive, runnable TypeScript val by augustohp
Script
import fetchBalanceFromCaptchaProvider from "https://esm.town/v/augustohp/CaptchaGetBalance";
export default async function fetchAntiCaptchaBalance(
token: string,
): Promise<number> {
pomdtr avatar
valshot
@pomdtr
Val Shot Usage https://pomdtr-valshot.web.val.run/v/<author>/<val> Example https://pomdtr-valshot.web.val.run/v/pomdtr/valshot
HTTP
return Response.redirect(imageURL);
export default router.fetch;
export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
const apiUrl = "https://sourcecodeshots.com/api/image/permalink";
const { url } = await ky.post(apiUrl, {
}).json();
return new URL(url);
async function fetchValCode(alias: string): Promise<string> {
const prefixUrl = "https://api.val.town/v1/alias";
const { code } = await ky.get(alias, { prefixUrl }).json();
frmysantana avatar
tanCrane
@frmysantana
An interactive, runnable TypeScript val by frmysantana
HTTP
import cheerio from "npm:cheerio";
export default async function tacoBellNutritionScrapper(req) {
const sourceUrl = `https://www.nutritionix.com/taco-bell/menu/premium`;
const siteText = await fetch(sourceUrl);