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=37&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 19261 results for "function"(936ms)

blog-cloneget-posts.ts1 match

@jamiesinclair•Updated 2 days ago
4
5// Get all blog posts (local + RSS)
6export async function getAllBlogPosts(): Promise<BlogPost[]> {
7 return (await Promise.all([
8 getNewPosts(),

blog-cloneget-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",

blog-cloneget-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;

blog-cloneFooter.tsx1 match

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

blog-cloneEXAMPLE.md1 match

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

blog-cloneByline.tsx1 match

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

blog-cloneBlogPost.tsx1 match

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

blog-clone2025-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, {

blogutil.tsx2 matches

@jamiesinclair•Updated 2 days ago
1export function formatDate(dateString: string): string {
2 try {
3 const date = new Date(dateString);
12}
13
14export function dayOfWeek(dateString: string): string {
15 try {
16 return new Date(dateString).toLocaleDateString("en-US", {

blogSocialLinks.tsx1 match

@jamiesinclair•Updated 2 days ago
2import { BlueskyIcon, DiscordIcon, GitHubIcon, RSSIcon, TwitterIcon } from "./icons.tsx";
3
4export default function SocialLinks() {
5 return (
6 <div className="social-links">

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": "*",