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=22&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 18796 results for "function"(871ms)

aqimain.tsx1 match

@pepicrft•Updated 23 hours ago
4const location = "prospect heights, brooklyn"; // <-- change to place, city, or zip code
5
6export async function aqi(interval: Interval) {
7 const data = await easyAQI({ location });
8 if (!interval.lastRunAt) {

slackbolt.tsx3 matches

@dinavinter•Updated 23 hours ago
68});
69
70/** Sample Function Listener */
71app.function("sample_step", async ({ client, inputs, fail, logger }) => {
72 try {
73 const { user_id } = inputs;
135})();
136
137export default async function handleGetRequest(): Promise<Response> {
138 const html = `
139 <html>

Scrape-Release-NotesCommitList.tsx1 match

@charmaine•Updated 23 hours ago
7}
8
9export function CommitList({ commits }: CommitListProps) {
10 const [expandedCommit, setExpandedCommit] = useState<string | null>(null);
11

Scrape-Release-NotesRepoSelector.tsx1 match

@charmaine•Updated 23 hours ago
13}
14
15export function RepoSelector({
16 owner,
17 repo,

luciaMagicLinkStarterUserProfile.tsx1 match

@cameronpak•Updated 23 hours ago
13}
14
15export function UserProfile({ user, onUpdate }: UserProfileProps) {
16 const [username, setUsername] = useState(user.username || "");
17 const [isEditing, setIsEditing] = useState(false);

luciaMagicLinkStartersessions.ts4 matches

@cameronpak•Updated 23 hours ago
4import { SESSIONS_TABLE, USER_TABLE } from "./schema.ts";
5
6export function generateSessionToken(): string {
7 const bytes = new Uint8Array(20);
8 crypto.getRandomValues(bytes);
11}
12
13export async function createSession(token: string, userId: number): Promise<Session> {
14 const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
15 const session: Session = {
25}
26
27export async function validateSessionToken(token: string): Promise<SessionValidationResult> {
28 const sessionId = encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
29 const { rows } = await sqlite.execute(
87}
88
89export async function invalidateSession(sessionId: string): Promise<void> {
90 await sqlite.execute(`DELETE FROM ${SESSIONS_TABLE} WHERE id = ?`, [sessionId]);
91}

luciaMagicLinkStarterschema.ts1 match

@cameronpak•Updated 23 hours ago
5export const MAGIC_LINKS_TABLE = "lucia_demo_magic_links_v2";
6
7async function createTables() {
8 await sqlite.execute(`
9 CREATE TABLE IF NOT EXISTS ${USER_TABLE} (

luciaMagicLinkStartermagic-links.ts4 matches

@cameronpak•Updated 23 hours ago
7
8// Hash a token using sha256
9function hashToken(token: string): string {
10 return encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
11}
12
13// Create a magic link token for the given email
14export async function createMagicLinkToken(userEmail: string): Promise<string> {
15 const token = generateSessionToken();
16 const tokenHash = hashToken(token);
27
28// Send a magic link email
29export async function sendMagicLinkEmail(url: string, userEmail: string, token: string): Promise<boolean> {
30 try {
31 const magicLink = `${url}/auth/magic-link/${token}`;
55
56// Validate a magic link token and create a session
57export async function validateMagicLinkToken(token: string): Promise<{ valid: boolean; userId?: number }> {
58 const now = Math.floor(Date.now() / 1000);
59 const tokenHash = hashToken(token);

luciaMagicLinkStarterLoginForm.tsx1 match

@cameronpak•Updated 23 hours ago
6}
7
8export function LoginForm({ onError }: LoginFormProps) {
9 const [email, setEmail] = useState("");
10 const [isSubmitting, setIsSubmitting] = useState(false);

luciaMagicLinkStarterApp.tsx1 match

@cameronpak•Updated 23 hours ago
16}
17
18export function App({ initialData }: { initialData: InitialData }) {
19 const [user, setUser] = useState<User | null>(initialData.user);
20 const [error, setError] = useState<string | null>(initialData.error);

getFileEmail4 file matches

@shouser•Updated 2 weeks 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": "*",