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%22Image%20title%22?q=function&page=6&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 18181 results for "function"(689ms)

telegramBotStartersendTelegramMessage.tsx1 match

@asdfg•Updated 15 hours ago
3 * Requires a Telegram Bot token as an environment variable
4 */
5export async function sendTelegramMessage(chatId: string, message: string) {
6 const botToken = Deno.env.get('TELEGRAM_BOT_TOKEN');
7

Townieusage-dashboard.ts4 matches

@valdottown•Updated 16 hours ago
4
5// Basic Auth middleware
6async function basicAuthMiddleware(req: Request): Promise<Response | null> {
7 const realm = "Usage Dashboard";
8 const unauthorizedResponse = new Response("Unauthorized", {
50}
51
52export default async function(req: Request) {
53 // Check authentication first
54 const authResponse = await basicAuthMiddleware(req);
286
287 <script>
288 document.addEventListener('DOMContentLoaded', function() {
289 // Add click event listeners to all tabs
290 document.querySelectorAll('.tab').forEach(tab => {
291 tab.addEventListener('click', function() {
292 const tabId = this.getAttribute('data-tab');
293

Townieschema.tsx2 matches

@valdottown•Updated 16 hours ago
20}
21
22async function createTables() {
23 await sqlite.execute(`
24 CREATE TABLE IF NOT EXISTS ${USAGE_TABLE} (
42}
43
44async function deleteTables() {
45 await sqlite.execute(`DROP TABLE IF EXISTS ${USAGE_TABLE}`);
46}

Towniequeries.tsx4 matches

@valdottown•Updated 16 hours ago
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9export async function getUser(bearerToken: string) {
10 if (userIdCache[bearerToken]) return userIdCache[bearerToken];
11
16}
17
18async function last24Hours(userId: string) {
19 const usage = await sqlite.execute(
20 `SELECT
37const DAILY_PRO_LIMIT = 5; // $5 per day
38
39export async function overLimit(bearerToken: string) {
40 const user = await getUser(bearerToken);
41 const last24HourUsage = await last24Hours(user.id);
44}
45
46export async function trackUsage({
47 bearerToken,
48 val_id,

TowniecalculateCost.tsx1 match

@valdottown•Updated 16 hours ago
5const CACHE_WRITE_RATE = 3.75; // $3.75 per M cache-write tokens
6
7export function calculateCost({
8 input_tokens,
9 output_tokens,

telegramBotStarterwebhookInfo.tsx1 match

@asdfg•Updated 16 hours ago
2 * Get information about the webhook status
3 */
4async function getWebhookInfo() {
5 try {
6 const botToken = process.env.TELEGRAM_BOT_TOKEN;

untitled-9126new-file-3797.tsx1 match

@xiaofei•Updated 16 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

untitled-6223README.md1 match

@xiaofei•Updated 16 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

untitled-5891new-file-3120.tsx1 match

@xiaofei•Updated 16 hours ago
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method === "OPTIONS") {
5 return new Response(null, {

testPondiversereport1 match

@argmn•Updated 16 hours ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function(req: Request): Promise<Response> {
4 let body;
5 try {

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
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",