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/$%7Burl%7D?q=function&page=2064&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 22656 results for "function"(1810ms)

authMiddlewaremain.tsx12 matches

@postpostscript•Updated 1 year ago
25};
26
27async function normalizeOption<T>(value: MaybeMethod<T>, req: Request, payload: JWTPayload): Promise<T> {
28 return value instanceof Function
29 ? await value(req, payload)
30 : value;
31}
32
33export function getRequestContextRequest(context: ImplementsRequestContext) {
34 return "raw" in context.req
35 ? context.req.raw
47}
48
49export function authWrapperCookie(
50 handler: (req: Request, context: ImplementsRequestContext) => MaybePromise<Response>,
51 options: AuthMiddlewareOptions<ImplementsRequestContext> & {
79}
80
81export function authWrapperToken(
82 handler: (req: Request, context: ImplementsRequestContext) => MaybePromise<Response>,
83 options: AuthMiddlewareOptions<ImplementsRequestContext> & {
109}
110
111export function authMiddlewareToken<Context extends ImplementsRequestContext>(
112 options: Omit<AuthMiddlewareOptions<Context>, "requestScope"> & {
113 createResponse?: (context: Context, content: unknown, init?: ResponseInit) => MaybePromise<Response>;
161}
162
163export function authMiddlewareTokenQS<Context extends ImplementsRequestContext>(
164 options: Omit<AuthMiddlewareOptions<Context>, "requestScope"> & {
165 createResponse?: (context: Context, content: unknown, init?: ResponseInit) => MaybePromise<Response>;
213}
214
215export function authMiddlewareCookie<Context extends ImplementsRequestContext>(
216 options: AuthMiddlewareOptions<Context> & {
217 rootPath?: string;
261 };
262
263 function verifyAuthToken(token: string, req: Request) {
264 return verifyThirdParty(token, {
265 issuer: `@${handle}/authId`,
371 };
372
373 newPayload.requestScope = requestScope instanceof Function
374 ? await requestScope(req, name)
375 : requestScope;
451};
452
453export function userDisplay(payload: JWTPayload) {
454 return payload.sub.replace(/\/.*/, "");
455}
456
457export function userActionsDisplay(
458 payload: JWTPayload,
459 {

jwksUtilsmain.tsx8 matches

@postpostscript•Updated 1 year ago
14export type JWTCustomClaimVerifier = (payload: jose.JWTPayload, claim: unknown) => MaybePromise<boolean>;
15
16export function createVerifyMethod(keys: () => MaybePromise<jose.JWK[]>) {
17 return async function verify(
18 token: string,
19 options: JWTVerifyOptions,
22 const { payload } = await jose.jwtVerify(token, publicKey, options);
23 const customClaims = options.custom && (
24 options.custom instanceof Function
25 ? await options.custom(payload)
26 : options.custom
31}
32
33export function createGenerateMethod(keys: () => MaybePromise<jose.JWK[]>) {
34 return async function generate(payload: any, exp?: string | number | Date) {
35 const _keys = await keys();
36 const privateKey = await jose.importJWK(_keys[0]);
51}
52
53export async function verifyThirdParty(
54 token: string,
55 options: JWTVerifyOptions = {},
72}
73
74export function decode(token: string) {
75 return jose.decodeJwt(token);
76}
116}
117
118export async function verifyCustomClaims(
119 payload,
120 customClaims: Record<string, unknown>,

whiteXerinaeREADME.md1 match

@stevekrouse•Updated 1 year ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37

whiteThrushREADME.md1 match

@stevekrouse•Updated 1 year ago
27- [ ] add visible output for non-query statements
28- [ ] add schema viewing
29- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
30- [ ] add refresh to table list sidebar after `CREATE/DROP/ALTER` statements
31- [ ] add automatic execution of initial select query on double click

greenEgretmain.tsx1 match

@cameron•Updated 1 year ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ name: "iasjdlkasj" });
3}

password_authmain.tsx7 matches

@stevekrouse•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)]);
105</html>`;
106
107export function redirect(location: string): Response {
108 return new Response(null, {
109 headers: {
123const cookieName = "auth_session";
124
125export function passwordAuth(next, options?: PasswordAuthOptions) {
126 let passwords: string[];
127 if (!options?.password) {

CFDatemain.tsx1 match

@vladimyr•Updated 1 year ago
4
5// @see: https://developer.apple.com/documentation/corefoundation/1542812-cfdategetabsolutetime#discussion
6export function toDate(cocoaTimestamp: number) {
7 return new Date(COCOA_REF_DATE.getTime() + cocoaTimestamp * 1000);
8}

googleFaviconsmain.tsx1 match

@vladimyr•Updated 1 year ago
3const GOOGLE_FAVICONS_BASE_URL = "https://www.google.com/s2/favicons";
4
5export function createFaviconURL(url: string | URL, size = 16): URL {
6 const { hostname } = new URL(url);
7 const faviconURL = new URL(GOOGLE_FAVICONS_BASE_URL);

MyFootermain.tsx2 matches

@leomp12•Updated 1 year ago
8const hello = Deno.env.get("HELLO_WORLD");
9
10export async function MyFooter(logo = valTownLogoAuto) {
11 const recommendation = rootValRef().handle === USERNAME
12 ? html`<span class="recommends">${await recommends()}</span>`
36}
37
38export default async function(req) {
39 const { Layout } = await import("https://esm.town/v/postpostscript/Layout");
40 return htmlResponse`${Layout`

extractHeaderCommentsmain.tsx1 match

@vladimyr•Updated 1 year ago
1// SPDX-License-Identifier: 0BSD
2
3export function extractHeaderComments(code: string) {
4 const comments: string[] = [];
5

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month 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.