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=746&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 7804 results for "function"(465ms)

tactfulCoffeeOctopusmain.tsx1 match

@charmaine•Updated 3 months ago
12const isProd = false;
13
14export async function twitterAlert({ lastRunAt }: Interval) {
15 // If isProd, search for tweets since that last time this interval ran
16 // if not, search for tweets since 48 hours ago for testing

ReactStaticmain.tsx3 matches

@jxnblk•Updated 3 months ago
22}
23
24export function render<T>(
25 /** Root-level React component that renders an entire <html> element
26 * including the head and body tags.
37 // }
38
39 return async function handler(request: Request): Promise<Response> {
40 const main = reactRender(Component);
41 const middleware: Middleware[] = [
66 Component: React.ComponentType<ReactStreamProps>,
67): Middleware =>
68 async function(req: DataRequest, res: Response): Promise<Response> {
69 const { renderToStaticMarkup } = await import("https://esm.sh/react-dom@18.3.1/server");
70

ReactStaticREADME.md4 matches

@jxnblk•Updated 3 months ago
7import { render, React } from "https://esm.town/v/jxnblk/ReactStatic";
8
9function App() {
10 return (
11 <html>
55```tsx
56// example middleware
57async function api (req: Request, res: Response, next): Promise<Response> {
58 if (req.pathname !== "/api") return next();
59 if (req.method === "POST") {
71```tsx
72// example middleware
73async function getInitialProps (req: Request, res: Response, next) {
74 // fetch data or do async work to pass as props to the component
75 req.data = {
88import { render } from "https://esm.town/v/jxnblk/ReactStatic";
89
90function App () {
91 return (
92 <html>

ReactStream_migratedmain.tsx3 matches

@jxnblk•Updated 3 months ago
22}
23
24export function render<T>(
25 /** Root-level React component that renders an entire <html> element
26 * including the head and body tags.
41 }
42
43 return async function handler(request: Request): Promise<Response> {
44 const main = reactStream(Component, module);
45 const middleware: Middleware[] = [
76 module: string | false,
77): Middleware =>
78 async function(req: DataRequest, res: Response): Promise<Response> {
79 const { renderToReadableStream } = await import("https://esm.sh/react-dom@18.3.1/server");
80

statusmain.tsx3 matches

@charmaine•Updated 3 months ago
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

prolificmain.tsx1 match

@stevekrouse•Updated 3 months ago
1import { db } from "https://esm.town/v/sqlite/db";
2
3export default async function(): Promise<Response> {
4 const res = await db.execute(
5 `SELECT author_username, count(*) as count

StripeDemomain.tsx4 matches

@charmaine•Updated 3 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [tipAmount, setTipAmount] = useState(5);
8 const paymentLinks = {
63}
64
65function Success() {
66 useEffect(() => {
67 confetti({
81}
82
83function client() {
84 const root = document.getElementById("root");
85 if (root) {
94if (typeof document !== "undefined") { client(); }
95
96export default async function server(request: Request): Promise<Response> {
97 const url = new URL(request.url);
98

templateTwitterAlertmain.tsx1 match

@valdottown•Updated 3 months ago
12const isProd = false;
13
14export async function twitterAlert({ lastRunAt }: Interval) {
15 // If isProd, search for tweets since that last time this interval ran
16 // if not, search for tweets since 48 hours ago for testing

passkeys_demomain.tsx3 matches

@maxm•Updated 3 months ago
23console.log("hi");
24// UTILS
25function generateJWT(userId: string) {
26 return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
27}
28function verifyJWT(token: string) {
29 return jwtVerify(token, SECRET);
30}
31function generateRandomString() {
32 return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
33}

comfortableOrangeSparrowmain.tsx2 matches

@charmaine•Updated 3 months ago
34}
35
36async function detectTechnologies(email_address: string): Promise<ShovelResponse> {
37 const domain = email_address.split("@")[1];
38
57}
58
59export async function newUserWelcomeEmail(req: Request): Promise<Response> {
60 if (req.method === "GET") return html(welcomeEmail);
61 if (req.headers.get("clerkNonSensitive") !== Deno.env.get("clerkNonSensitive"))

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago