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/$2?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 24046 results for "function"(2210ms)

Email253 words

https://docs.val.town/vals/email/
email function in the standard library. Type Signature. Files triggered by Email receive an argument called Email that represents the email that was sent. Here’s an example: Example export async

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. Files triggered by Email receive an argument called Email that represents the email that was sent. Here’s an example: Example export async function emailValHandler(email: Email) { console.log("Email received!",

Cron257 words

https://docs.val.town/vals/cron/
morning. Crons can be configured with cron syntax, or simple intervals like “once an hour” Functions can run up to once every 15 minutes, or once a minute, with the

Sections

Cron

morning. Crons can be configured with cron syntax, or simple intervals like “once an hour” Functions can run up to once every 15 minutes, or once a minute, with the

Type Signature

Type Signature. Crons take an Interval object as a parameter, and can return anything as a result. The return value is ignored. ExampleRun in Val Town ↗ export function cronValHandler(interval:

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 Webhook364 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.

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

Stripe714 words

https://docs.val.town/integrations/stripe/
@ts-ignore. import { Stripe } from "npm:stripe"; const stripe = new Stripe(Deno.env.get("STRIPE_TEST_API_KEY")); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); if (url.pathname === "/") {

Sections

Stripe Checkout

@ts-ignore. import { Stripe } from "npm:stripe"; const stripe = new Stripe(Deno.env.get("STRIPE_TEST_API_KEY")); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); if (url.pathname === "/") {

Example Val Town Stripe Webhook

from "npm:stripe"; const stripe = new Stripe( Deno.env.get("stripe_sk_customer_readonly") as string, { apiVersion: "2020-08-27", } ); function getStripeCustomer(customerId: string) { return stripe.customers.retrieve(customerId); } export let newStripeEvent = async (req: Request) =>

Upgrade Guide: Safer Val Scopes333 words

https://docs.val.town/troubleshooting/std-set-permission-error/
is deprecated and we now use blob storage with our std/blob library instead. The equivalent function to std.set() is blob.setJSON(). // Using std/set. import { set } from "https://esm.town/v/std/set"; set("createdAt",

Sections

Use Blob Storage Instead (recommended)

Use Blob Storage Instead (recommended). Std/set is deprecated and we now use blob storage with our std/blob library instead. The equivalent function to std.set() is blob.setJSON(). // Using std/set. import

Permission errors334 words

https://docs.val.town/troubleshooting/permission-errors/
to your secrets (--allow-env). Some system information (--allow-sys=osRelease,homedir,cpus,hostname) This allows you to access the following functionality: import os from "node:os"; os.cpus(); os.homedir(); Deno.osRelease(); Deno.hostname(); These values are not particularly useful,

Sections

Allowed permissions

Allowed permissions. Vals have the following permissions: Network access (--allow-net). Environment access, limited to your secrets (--allow-env). Some system information (--allow-sys=osRelease,homedir,cpus,hostname) This allows you to access the following functionality: import

reactHonoExampleREADME.md2 matches

@notmart•Updated 1 hour ago
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.

reactHonoExamplequeries.ts2 matches

@notmart•Updated 1 hour ago
10await createTables();
11
12export async function getMessages(limit = MESSAGE_LIMIT): Promise<Message[]> {
13 const messages = await sqlite.execute(
14 `SELECT * FROM ${tableName}
20}
21
22export async function insertMessage(content: string) {
23 await sqlite.execute(
24 `INSERT INTO ${tableName} (content)

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.