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/$%7Burl%7D?q=function&page=33&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 19200 results for "function"(866ms)

blogget-old-posts.ts2 matches

@jamiesinclair•Updated 2 days ago
4const OLD_BLOG_RSS = "https://val-town-blog.pages.dev/rss.xml";
5// Get blog posts from RSS feed
6async function getOldPosts(): Promise<BlogPost[]> {
7 const parser = new RssParser();
8 const feed = await parser.parseURL(OLD_BLOG_RSS);
289 "slug": "deprecating-the-run-api",
290 "link": "/blog/deprecating-the-run-api",
291 "description": "Not every function should be an API",
292 "pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293 "author": "André Terron",

blogget-new-posts.ts2 matches

@jamiesinclair•Updated 2 days ago
5
6// Get all blog posts from the file system
7export async function getNewPosts(): Promise<BlogPost[]> {
8 const files = await listFiles(import.meta.url);
9 const blogPostFiles = files.filter(
42
43// Get a single blog post by slug
44export async function getBlogPostBySlug(slug: string): Promise<BlogPost | null> {
45 const post = posts.find(post => post.slug.includes(slug));
46 return post;

blogFooter.tsx1 match

@jamiesinclair•Updated 2 days ago
5const year = new Date().getFullYear();
6
7export default function Footer () {
8 return (
9 <footer className="container">

blogEXAMPLE.md1 match

@jamiesinclair•Updated 2 days ago
21
22```typescript
23function hello() {
24 console.log("Hello, Val Town!");
25}

blogByline.tsx1 match

@jamiesinclair•Updated 2 days ago
2import { formatDate, dayOfWeek } from "./util.tsx";
3
4export default function Byline ({ post }: {
5 post: {
6 author: string;

blogBlogPost.tsx1 match

@jamiesinclair•Updated 2 days ago
10}
11
12export function BlogPostComponent({ post, content }: BlogPostProps) {
13 return (
14 <Layout title={post.title}>

blog2025-04-08-migration.md2 matches

@jamiesinclair•Updated 2 days ago
83We didn't. We left them where they are, and proxy to them.
84
85Writing a proxy in Val Town (or any functions platform with the ['fetch handler' interface](https://blog.val.town/blog/the-api-we-forgot-to-name/)) is a delight:
86
87```ts
88const OLD_BLOG_HOST = "https://val-town-blog.pages.dev/";
89export async function proxy(req: Request): Promise<Response> {
90 const url = new URL(req.url);
91 return fetch(OLD_BLOG_HOST + url.pathname + url.search, {

TownieMessages.tsx8 matches

@valdottown•Updated 2 days ago
14};
15
16export function Messages ({
17 messages,
18 messageEndTimes,
40}
41
42function Message ({
43 message,
44 messageEndTimes,
60}
61
62function AssistantMessage ({ message, messageEndTimes, running }: {
63 message: Message;
64 messageEndTimes: Record<string, number>;
85}
86
87function Part ({ part }) {
88 switch (part.type) {
89 case "text":
100}
101
102function TextPart ({ part }) {
103 return (
104 <ReactMarkdown>
108}
109
110function ToolPart ({ part }) {
111 const {
112 toolName,
167}
168
169function EditorToolPart ({ part }) {
170 const {
171 toolName,
233}
234
235function UserMessage ({ message }: {
236 message: Message;
237}) {

markdownBlogStarterLayout.tsx1 match

@dev223•Updated 2 days ago
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">

markdownBlogStarterindex.tsx3 matches

@dev223•Updated 2 days ago
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 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": "*",