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/?q=function&page=654&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 8275 results for "function"(652ms)

hello_worldfileCreated.ts1 match

@shouser•Updated 1 month ago
1export default async function(req: Request): Promise<Response> {
2 try {
3 if (req.method !== "POST") {

static_reactdemo.http.tsx1 match

@jxnblk•Updated 1 month ago
4import reactRender from "./react-render.tsx";
5
6function Demo () {
7 return (
8 <html>

static_reactindex.tsx2 matches

@jxnblk•Updated 1 month ago
3export type Middleware = (req: DataRequest, res: Response, callback: NextCallback) => Promise<Response>;
4
5export function render<T>(...args: Middleware[]) {
6 const middleware: Middleware[] = args.slice().filter(Boolean);
7
8 return async function handler(request: Request): Promise<Response> {
9
10 let res: Response = new Response();

digestupdate1 match

@strysg•Updated 1 month ago
107];
108
109export default async function(interval: Interval) {
110 try {
111 const news = await updateNews(sources);

static_reactreact-render.tsx1 match

@jxnblk•Updated 1 month ago
5
6export const reactRender = (Component: React.ComponentType) => {
7 return async function (req: DataRequest, res: Response): Promise<Response> {
8 const html = renderToStaticMarkup(<Component />);
9 const headers = res.headers;

project_updates_webhookmigrations.ts1 match

@shouser•Updated 1 month ago
4export const projectStatesTableName = "project_creation_project_states";
5
6export async function createTables() {
7 await sqlite.batch([
8 `CREATE TABLE IF NOT EXISTS ${subscriptionsTableName} (

project_updates_webhookwebhookService.ts1 match

@shouser•Updated 1 month ago
1export async function sendWebhookNotification(url: string, data: any) {
2 try {
3 const response = await fetch(url, {

project_updates_webhookqueries.ts4 matches

@shouser•Updated 1 month ago
10await createTables();
11
12export async function getWebhooks(limit = WEBHOOK_LIMIT): Promise<Webhook[]> {
13 const webhooks = await sqlite.execute(
14 `SELECT * FROM ${subscriptionsTableName}
20}
21
22export async function insertWebhook(projectId: string, webhookUrl: string, event: string) {
23 await sqlite.execute(
24 `INSERT INTO ${subscriptionsTableName} (projectId, webhookUrl, event)
28}
29
30export async function getProjectState(projectId: string) {
31 const result = await sqlite.execute(
32 `SELECT * FROM ${projectStatesTableName}
47}
48
49export async function updateProjectState(projectId: string, files: any[]) {
50 await sqlite.execute(
51 `INSERT OR REPLACE INTO ${projectStatesTableName} (projectId, files, lastUpdated)
dotcom

dotcomapp.tsx17 matches

@jxnblk•Updated 1 month ago
25const cx = (...cn) => cn.filter(Boolean).join(" ");
26
27export function App(props) {
28 const cookies: AppCookies = parseCookies(props.cookie || null);
29 const initColorIndex = cookies.color || 0;
61// TODO: 404
62
63function Head(props) {
64 const { post } = props.data;
65 let params = "";
106const S = () => <>{" "}</>;
107
108function Nav() {
109 return (
110 <>
126}
127
128function Header({ cycleColor }: {
129 cycleColor: () => void;
130}) {
154}
155
156function Footer(props) {
157 return (
158 <footer className="container mb2 mt2">
184}
185
186function Home(props) {
187 return (
188 <div className="container space-children">
231}
232
233function Unknown(props) {
234 return (
235 <div className="container">
239}
240
241function NovanticaPromoHero() {
242 return (
243 <section className="promo">
255}
256
257function NovanticaPromoFooter() {
258 return (
259 <section className="promo mt2 mb2">
279const timestamp = (date: Date | string) => new Date(date).toLocaleDateString("en-US", { timeZone: "UTC" });
280
281function PostHeader({ post, primary }: { post: PostData; primary?: boolean }) {
282 const Element = primary ? "h1" : "h3";
283 return (
297}
298
299function PostList({ posts }) {
300 return (
301 <>
320}
321
322function RecentPosts({ data }) {
323 const recent = (data?.posts || [])
324 .filter(p => !p.draft)
337}
338
339function Blog({ data }) {
340 const posts = data.posts.filter(p => !p.draft);
341 return (
354}
355
356function Post({ data }) {
357 const { post } = data;
358 return (
381};
382
383export const routes: Record<Route, React.FunctionComponent> = {
384 [Route.Home]: Home,
385 [Route.Blog]: Blog,
388};
389
390export function setCookie(key: string, value: string) {
391 fetch("/", {
392 method: "POST",
395}
396
397function parseCookies(cookies: string) {
398 return (cookies || "").split(";").reduce((acc, n) => {
399 const [key, value] = n.split("=").map(s => s.trim());

vtClaudemain.http.tsx1 match

@maxm•Updated 1 month ago
359);
360
361export default async function(req: Request): Promise<Response> {
362 const url = new URL(req.url);
363 const path = url.pathname;

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago