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/$%7Bsuccess?q=function&page=7&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 18129 results for "function"(823ms)

TownieuseCreateBranch.tsx1 match

@stdโ€ขUpdated 3 hours ago
4const ENDPOINT = "/api/create-branch";
5
6export function useCreateBranch (projectId: string) {
7 const { token } = useAuth();
8 const [data, setData] = useState<any>(null);

TownieuseChatLogic.ts1 match

@stdโ€ขUpdated 3 hours ago
13}
14
15export function useChatLogic({
16 project,
17 branchId,

TownieuseBranches.tsx1 match

@stdโ€ขUpdated 3 hours ago
4const ENDPOINT = "/api/project-branches";
5
6export function useBranches (projectId: string) {
7 const { token } = useAuth();
8 const [data, setData] = useState<any>(null);

TownieuseAuth.tsx1 match

@stdโ€ขUpdated 3 hours ago
5const ANTHROPIC_KEY = "anthropic_api_key";
6
7export function useAuth () {
8 const [token, setToken, removeToken] = useLocalStorage(TOKEN_KEY, "");
9 const [anthropicApiKey, setAnthropicApiKey, removeAnthropicApiKey] = useLocalStorage(ANTHROPIC_KEY, "");

Townietext-editor.ts7 matches

@stdโ€ขUpdated 3 hours ago
3import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
4
5function printFileType(file: any){
6 if (file.type === "interval")
7 return " (cron)"
14 * View a file or directory in a Val Town project
15 */
16async function view(
17 vt: ValTown,
18 project: any,
71 * Replace a string in a file in a Val Town project
72 */
73async function str_replace(
74 vt: ValTown,
75 project: any,
133 * Create a new file in a Val Town project
134 */
135async function create(vt: ValTown, project: any, branch_id: string | undefined, path: string, file_text?: string) {
136 let type_: "file" | "http" | "script";
137 if (path.includes("backend/index.ts")) type_ = "http";
167 * Insert a string at a specific line in a file in a Val Town project
168 */
169async function insert(
170 vt: ValTown,
171 project: any,
210 * Undo the last edit to a file in a Val Town project (not implemented)
211 */
212async function undo_edit(vt: ValTown, project: any, branch_id: string | undefined) {
213 return {
214 type: "error",
220 * Creates a text editor tool for editing files in a Val Town project
221 */
222export function getTextEditorTool(bearerToken: string, project: any, branch_id: string | undefined) {
223 const vt = new ValTown({ bearerToken });
224 return anthropic.tools.textEditor_20250124({

Towniesystem_prompt.txt12 matches

@stdโ€ขUpdated 3 hours 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}
40
41```ts
42export default async function () {
43 // Scheduled task code
44}
52
53```ts
54export default async function (email: Email) {
55 // Process email
56}
60## Val Town Standard Libraries
61
62Val Town provides several hosted services and utility functions.
63
64### Blob Storage
114```
115
116## Val Town Utility Functions
117
118Val Town provides several utility functions to help with common project tasks.
119
120### Importing Utilities
194โ”‚ โ”œโ”€โ”€ database/
195โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
196โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
197โ”‚ โ”‚ โ””โ”€โ”€ README.md
198โ”‚ โ””โ”€โ”€ routes/ # Route modules
213โ””โ”€โ”€ shared/
214 โ”œโ”€โ”€ README.md
215 โ””โ”€โ”€ utils.ts # Shared types and functions
216```
217
220- Hono is the recommended API framework
221- Main entry point should be `backend/index.ts`
222- **Static asset serving:** Use the utility functions to read and serve project files:
223 ```ts
224 import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
254- Run migrations on startup or comment out for performance
255- Change table names when modifying schemas rather than altering
256- Export clear query functions with proper TypeScript typing
257
258## Common Gotchas and Solutions

Towniestyles.css2 matches

@stdโ€ขUpdated 3 hours ago
160 transition-property: background-color;
161 transition-duration: 400ms;
162 transition-timing-function: linear;
163}
164
769 transition-property: color, background-color, border-color, opacity;
770 transition-duration: 200ms;
771 transition-timing-function: ease-in-out;
772}
773

TowniesoundEffects.ts3 matches

@stdโ€ขUpdated 3 hours ago
1/**
2 * Sound effects utility functions for the application
3 */
4
7 * @returns A Promise that resolves when the sound has started playing
8 */
9export function playBellSound(): Promise<void> {
10 return new Promise((resolve) => {
11 try {
69 * @returns A Promise that resolves when the sound has started playing
70 */
71export function playSimpleNotification(): Promise<void> {
72 return new Promise((resolve) => {
73 try {

TownieRequireAuthRoute.tsx1 match

@stdโ€ขUpdated 3 hours ago
7import { useAuth } from "../hooks/useAuth.tsx";
8
9export function RequireAuthRoute () {
10 const location = useLocation();
11 const { isAuthenticated } = useAuth();

TownieProjectsRoute.tsx3 matches

@stdโ€ขUpdated 3 hours ago
4import { Loading } from "./Loading.tsx";
5
6export function ProjectsRoute () {
7 const projects = useProjects();
8
42}
43
44function ProjectCard ({
45 user,
46 project,
81}
82
83function Privacy ({ privacy }: {
84 privacy: "public"|"unlisted"|"private";
85}) {

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