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/image-url.jpg%20%22Optional%20title%22?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 18380 results for "function"(919ms)

Email218 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!",

Cron (Scheduled)258 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 (Scheduled)

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

Val Town Docs181 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.

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

telegramBotStarterbotFunctions.js19 matches

@asdfg•Updated 1 hour ago
1// ============================================================
2// CORE FUNCTIONALITY
3// ============================================================
4import storage from "./storage.js";
7 * Expose this as an HTTP endpoint in Val.town
8 */
9async function handleTelegramWebhook(req) {
10 try {
11 const update = await req.json();
50 * Process commands from the owner
51 */
52async function processOwnerCommand(message) {
53 const text = message.text || "";
54
188 * Get information about a user
189 */
190async function getUserInfo(userId) {
191 return await storage.get(`userInfo:${userId}`);
192}
195 * Get list of all active users who have messaged the bot
196 */
197async function getActiveUsers() {
198 const keys = await storage.list({ prefix: "userInfo:" });
199 const users = [];
211 * Get list of blocked user IDs
212 */
213async function getBlockedUsers() {
214 return await storage.get("blockedUsers") || [];
215}
218 * Block a user
219 */
220async function blockUser(userId) {
221 const blockedUsers = await getBlockedUsers();
222 userId = userId.toString();
233 * Unblock a user
234 */
235async function unblockUser(userId) {
236 const blockedUsers = await getBlockedUsers();
237 userId = userId.toString();
253 * Store a message in the database
254 */
255async function storeMessage(userId, userName, text, direction) {
256 const messages = await getMessages(userId) || [];
257
280 * Get message history for a specific user
281 */
282async function getMessages(userId) {
283 return await storage.get(`messages:${userId}`) || [];
284}
287 * Notify the owner about new incoming messages
288 */
289async function notifyOwner(userId, userName, messageText) {
290 const ownerChatId = process.env.OWNER_CHAT_ID;
291
300 * Reply to a specific user
301 */
302async function replyToUser(userId, text) {
303 // Send the message to the user
304 const success = await sendTelegramMessage(userId, text);
334 * Send a message using the Telegram API
335 */
336async function sendTelegramMessage(chatId, text) {
337 try {
338 const botToken = process.env.TELEGRAM_BOT_TOKEN;
357
358// ============================================================
359// SETUP FUNCTIONS
360// ============================================================
361
364 * Use this once during initial setup
365 */
366async function setupWebhook(webhookUrl) {
367 try {
368 const botToken = process.env.TELEGRAM_BOT_TOKEN;
388 * Get information about the webhook status
389 */
390async function getWebhookInfo() {
391 try {
392 const botToken = process.env.TELEGRAM_BOT_TOKEN;
404 * Send a welcome message to yourself to verify the bot is working
405 */
406async function testBot() {
407 const ownerChatId = process.env.OWNER_CHAT_ID;
408
425}
426
427// Export the functions
428export default {
429 // Main webhook handler
430 telegram: handleTelegramWebhook,
431
432 // Setup and utility functions
433 setupWebhook,
434 getWebhookInfo,

EEPMOnitoringlogin.tsx1 match

@solomonferede•Updated 1 hour ago
8};
9
10export function LoginForm({ onLogin }) {
11 const [username, setUsername] = useState("");
12 const [password, setPassword] = useState("");

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks 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.