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=1517&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 17289 results for "function"(2677ms)

sqliteBuildermain.tsx1 match

@postpostscript•Updated 1 year ago
84}
85
86export function Statement(
87 strings: TemplateStringsArray,
88 ...replacements: (InValue | StatementInstance)[]

password_authmain.tsx7 matches

@parkerdavis•Updated 1 year ago
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
60}
61
62async function fetchUser(token: string): Promise<{ id: string }> {
63 const resp = await fetch("https://api.val.town/v1/me", {
64 headers: {
74}
75
76async function verifyApiToken(token: string) {
77 try {
78 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);
106</html>`;
107
108export function redirect(location: string): Response {
109 return new Response(null, {
110 headers: {
124const cookieName = "auth_session";
125
126export function passwordAuth(next, options?: PasswordAuthOptions) {
127 let passwords: string[];
128 if (!options?.password) {

periodicCertCheckmain.tsx1 match

@agmm•Updated 1 year ago
3import { email } from "https://esm.town/v/std/email";
4
5export default async function(interval: Interval) {
6 const domain = "agmm.xyz";
7 const results = await getCertificates(domain);

viewSourcemain.tsx1 match

@neverstew•Updated 1 year ago
3import { escape } from "npm:html-sloppy-escaper";
4
5export default async function viewSource(req: Request) {
6 const pathname = new URL(req.url).pathname;
7 const html = await fetchText(pathname === "/" ? "example.com" : pathname).then(prettifyHtml);

example_ssrmain.tsx3 matches

@pomdtr•Updated 1 year ago
3
4// will run on both client and server
5export function Demo(props: { items: string[] }) {
6 const [items, setItems] = useState(props.items);
7 useEffect(() => {
26}
27
28// You server code should be contained in this function
29export default async function (req: Request) {
30 const url = new URL(req.url);
31 if (url.pathname == "/api/item") {

islandmain.tsx1 match

@pomdtr•Updated 1 year ago
3import React from "https://esm.sh/react";
4
5export function Island({
6 src,
7 name,

observable_esmmain.tsx1 match

@mootari•Updated 1 year ago
6import * as module from ${JSON.stringify(url)};
7
8export default function define(runtime, observer) {
9 const main = runtime.module();
10 main.variable(observer("__module")).define("__module", () => module);

renderFormAndSaveDataREADME.md1 match

@andreterron•Updated 1 year ago
1# Render form and save data
2
3This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
4
5Fork this val to customize it and use it on your account.

myApimain.tsx1 match

@tonycheal•Updated 1 year ago
1export function myApi(name) {
2 return "hi " + name;
3}

httpMockingExamplemain.tsx1 match

@tmcw•Updated 1 year ago
4 * member.
5 */
6export const httpHandler = async function(req: Request): Promise<Response> {
7 if (req.method !== "POST") return new Response("Bad request: only POST allowed", { status: 400 });
8 const body = await req.json();

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",