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=72&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 20188 results for "function"(1212ms)

TownieChatRoute.tsx3 matches

@valdottownโ€ขUpdated 1 day ago
14import { Loading } from "./Loading.tsx";
15
16export function ChatRoute() {
17 const { projectId, branchId } = useParams() as {
18 projectId: string;
50}
51
52function Conversation({
53 project,
54 files,
163}
164
165function shouldRefetch(message) {
166 for (let i = 0; i < message?.parts?.length; i++) {
167 let part = message.parts[i];

TownieBranchSelect.tsx1 match

@valdottownโ€ขUpdated 1 day ago
7const NEW_BRANCH_VAL = "__NEW_BRANCH__";
8
9export function BranchSelect() {
10 const { projectId, branchId } = useParams() as {
11 projectId: string;

TownieApp.tsx1 match

@valdottownโ€ขUpdated 1 day ago
18});
19
20export function App() {
21 const [audio, setAudio] = useLocalStorage("AUDIO", false);
22 const user = useUser();

TownieuseUser.tsx1 match

@valdottownโ€ขUpdated 1 day ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieInlinePreview.tsx2 matches

@valdottownโ€ขUpdated 1 day ago
4import { MessageContext } from "./Messages.tsx";
5
6export function InlinePreview ({ part }) {
7 const project = useContext(ProjectContext);
8 const message = useContext(MessageContext);
73const SCREENSHOT_URL = "https://screenshots.valtown.net/screenshot.png";
74
75function getScreenshotURL ({
76 version,
77 endpoint,

TownieChatRouteSingleColumn.tsx3 matches

@valdottownโ€ขUpdated 1 day ago
19
20// alt single-column version of /chat route
21export function ChatRouteSingleColumn () {
22 const { projectId, branchId } = useParams() as {
23 projectId: string;
56}
57
58function Conversation ({
59 project,
60 files,
177}
178
179function shouldRefetch (message) {
180 for (let i = 0; i < message?.parts?.length; i++) {
181 let part = message.parts[i];

Townie.cursorrules12 matches

@valdottownโ€ขUpdated 1 day ago
4
5- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
20
21## Types of triggers
28
29```ts
30export default async function (req: Request) {
31 return new Response("Hello World");
32}
42
43```ts
44export default async function () {
45 // Scheduled task code
46}
56
57```ts
58export default async function (email: Email) {
59 // Process email
60}
66## Val Town Standard Libraries
67
68Val Town provides several hosted services and utility functions.
69
70### Blob Storage
120```
121
122## Val Town Utility Functions
123
124Val Town provides several utility functions to help with common project tasks.
125
126### Importing Utilities
200โ”‚ โ”œโ”€โ”€ database/
201โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
202โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
203โ”‚ โ”‚ โ””โ”€โ”€ README.md
204โ”‚ โ””โ”€โ”€ routes/ # Route modules
219โ””โ”€โ”€ shared/
220 โ”œโ”€โ”€ README.md
221 โ””โ”€โ”€ utils.ts # Shared types and functions
222```
223
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
229 ```ts
230 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263
264## Common Gotchas and Solutions

Natindex.html4 matches

@Nataliaโ€ขUpdated 1 day ago
507 <li><a href="#" class="text-gray-400 hover:text-white transition">Birthday Parties</a></li>
508 <li><a href="#" class="text-gray-400 hover:text-white transition">Private Events</a></li>
509 <li><a href="#" class="text-gray-400 hover:text-white transition">Corporate Functions</a></li>
510 <li><a href="#" class="text-gray-400 hover:text-white transition">Photography Services</a></li>
511 <li><a href="#" class="text-gray-400 hover:text-white transition">Catering Coordination</a></li>
527 <script>
528 // Booking form submission
529 document.getElementById('bookingForm').addEventListener('submit', async function(e) {
530 e.preventDefault();
531
573
574 // Contact form submission
575 document.getElementById('contactForm').addEventListener('submit', function(e) {
576 e.preventDefault();
577
589 // Smooth scrolling for navigation links
590 document.querySelectorAll('a[href^="#"]').forEach(anchor => {
591 anchor.addEventListener('click', function(e) {
592 e.preventDefault();
593
react-router-data-mode-starter

react-router-data-mode-starterapi.tsx1 match

@jxnblkโ€ขUpdated 1 day ago
1export default async function (req: Request): Promise<Response> {
2 // fake data API
3 return Response.json([
react-router-data-mode-starter

react-router-data-mode-starterroutes.tsx5 matches

@jxnblkโ€ขUpdated 1 day ago
11const API_URL = "https://jxnblk--bc1e880c319511f0bf2d569c3dd06744.web.val.run";
12
13function HTML ({ children }: {
14 children: React.ReactNode;
15}) {
26}
27
28function Layout () {
29 return (
30 <HTML>
52}
53
54function Home () {
55 const [count, setCount] = React.useState(0);
56 return (
63}
64
65function About () {
66 const data = useLoaderData();
67
74}
75
76async function catsLoader () {
77 const data = await fetch(API_URL)
78 .then(res => res.json());

getFileEmail4 file matches

@shouserโ€ขUpdated 3 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
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.