Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=2&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 7147 results for "function"(231ms)

Proxied fetch207 words

https://docs.val.town/std/fetch/
contains an alternative version, std/fetch, that wraps the JavaScript Fetch API to provide additional functionality. The fetch function from std/fetch reroutes requests using a proxy vendor so that requests obtain

Sections

Proxied fetch

contains an alternative version, std/fetch, that wraps the JavaScript Fetch API to provide additional functionality. The fetch function from std/fetch reroutes requests using a proxy vendor so that requests obtain

Migrating Deprecated HTTP Vals541 words

https://docs.val.town/troubleshooting/migrating-deprecated-http-vals/
return a different random number on each request: const randomValue = Math.random(); export default async function (req: Request): Promise<Response> { return Response.json({ randomValue }); } Run in Val Town. Terminal

Sections

Accidentally re-using values.

return a different random number on each request: const randomValue = Math.random(); export default async function (req: Request): Promise<Response> { return Response.json({ randomValue }); } Run in Val Town. Terminal

Intentionally caching values for performance!

data fetching. const expensiveData = await fetchLargeDataset(); const cache = new Map(); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); const key = url.searchParams.get("key"); if

Migration Checklist

be safely cached. Move variables that need to be unique per request inside the handler function. Consider opportunities to improve performance by intentionally caching expensive computations or initializations. Test your

Email218 words

https://docs.val.town/vals/email/
team emails to Discord / Slack. Tip. Vals can send email, too! Using the email function in the standard library. Type Signature. Email vals receive an argument called Email that

Sections

Email

team emails to Discord / Slack. Tip. Vals can send email, too! Using the email function in the standard library.

Type Signature

Type Signature. Email vals receive an argument called Email that represents the email that was sent to the val. Here’s an example of an email val: Example export async function

Overview116 words

https://docs.val.town/vals/
in ChatGPT Ask questions about this page. What is a val? Vals are hosted JavaScript functions. Vals run on the Val Town serverless platform. Vals can import other vals, NPM,

Sections

What is a val?

What is a val? Vals are hosted JavaScript functions. Vals run on the Val Town serverless platform. Vals can import other vals, NPM, and more ↗ Vals can be public,

Send Discord message via webhook125 words

https://docs.val.town/integrations/discord/send-message/
{ "Content-Type": "application/json", }, body: JSON.stringify({ content }), }); if (text.length) throw Error("Discord Webhook error: " + text); }; You can browse example usages of this function here. Example Integration.

Sections

Send Discord message via webhook

throw Error("Discord Webhook error: " + text); }; You can browse example usages of this function here.

Receiving a GitHub Webhook361 words

https://docs.val.town/integrations/github/receiving-a-github-webhook/
at the Recent Deliveries page of your webhook. Securing GitHub Webhooks. Once public, your val function will listen for any payload sent to its endpoint. For security reasons, you probably

Sections

Securing GitHub Webhooks

Once public, your val function will listen for any payload sent to its endpoint. For security reasons, you probably want to limit requests to those coming from GitHub. One method

RSS145 words

https://docs.val.town/guides/rss/
"https://esm.town/v/std/email?v=9"; import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems"; import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds"; export async function pollRSSFeeds({ lastRunAt }: Interval) { return Promise.all( Object.entries(rssFeeds).map(async ([name, url]) => { let items

Sections

Polling RSS

"https://esm.town/v/std/email?v=9"; import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems"; import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds"; export async function pollRSSFeeds({ lastRunAt }: Interval) { return Promise.all( Object.entries(rssFeeds).map(async ([name, url]) => { let items

ORMs197 words

https://docs.val.town/std/sqlite/orms/
await db.select().from(kv).all(); console.log(sqliteDrizzleExample); Prisma. 🚫 Prisma isn’t supported in Val Town because it relies on functionality that only exists in a classic server environment. Sequelize. 🚫 Sequelize isn’t supported in

Sections

Prisma

Prisma. 🚫 Prisma isn’t supported in Val Town because it relies on functionality that only exists in a classic server environment.

Val Town Docs211 words

https://docs.val.town/
questions about this page. Val Town is a collaborative website to create and scale JavaScript functions. Create APIs, crons, store data – all from the browser, and deployed in miliseconds.

Sections

Val Town Docs

questions about this page. Val Town is a collaborative website to create and scale JavaScript functions. Create APIs, crons, store data – all from the browser, and deployed in miliseconds.

Importing664 words

https://docs.val.town/reference/import/
mind, and won’t work with Deno. While Deno implements most of the functionality of Node.js and some of the functionality of browsers - so many modules will “just work” in

Sections

Look for Deno compatibility

mind, and won’t work with Deno. While Deno implements most of the functionality of Node.js and some of the functionality of browsers - so many modules will “just work” in

pondiverseaddCreation1 match

@iliazeus•Updated 9 hours ago
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 // body contains:
8 // - title (string)

JimeluStevenshandleAccountantEmail1 match

@luke_f•Updated 10 hours ago
1import { DateTime } from "https://esm.sh/luxon@3.4.4";
2
3export default async function(e: Email) {
4 console.log("Received accountant email");
5 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");

getFileEmail4 file matches

@shouser•Updated 4 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago