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=768&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"(517ms)

codeIconReactmain.tsx1 match

@jxnblk•Updated 11 months ago
2import React from "npm:react";
3
4export default function CodeIcon(props: React.SVGProps<SVGSVGElement>) {
5 return (
6 <svg

unawaitedAsyncExamplemain.tsx1 match

@stevekrouse•Updated 11 months ago
1export async function handle() {
2 // Schedule work to do later
3 (async () => {

exampleHTTPmain.tsx1 match

@stevekrouse•Updated 11 months ago
1export function handler(request: Request) {
2 return Response.json({ ok: true });
3}

codemirrorTsBrowserREADME.md2 matches

@maxm•Updated 11 months ago
10import { renderToString } from "npm:react-dom/server";
11
12export default async function(req: Request): Promise<Response> {
13 return new Response(
14 renderToString(
19 {`let hasAnError: string = 10;
20
21function increment(num: number) {
22 return num + 1;
23}

reppmain.tsx5 matches

@maxm•Updated 11 months ago
52
53// The script we run within the worker. Don't reference anything
54// outside of this function as it won't be available within the worker. We could even host this in a separate val and pass
55const workerScript = () => {
56 type Log = {
64 get(target, key) {
65 const real = target[key];
66 if (typeof real === "function" && typeof key === "string") {
67 const fn = function(...args: any[]) {
68 logs.push({
69 level: key,
79 },
80 });
81 async function evaluate(url) {
82 try {
83 const _ = await import(url);
170
171// // evaluate("let ten = 10");
172// // evaluate("function cube(x) { return x ** 3 }");
173// // evaluate("ten + cube(3)");
174// evaluate(`

valTownLogotypeReactmain.tsx1 match

@jxnblk•Updated 11 months ago
2import React from "npm:react";
3
4export default function ValTownLogo(props: React.SVGProps<SVGSVGElement>) {
5 return (
6 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 442 79" {...props}>

tinygoHttpExampleREADME.md1 match

@maxm•Updated 11 months ago
18const resp = await fetch("https://maxm-wasmblobhost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm");
19const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
20export default async function(req: Request): Promise<Response> {
21 return handler(req);
22}

staticChessREADME.md1 match

@maxm•Updated 11 months ago
9Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
10
11Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
12
13Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.

vtOpenAPImain.tsx1 match

@stevekrouse•Updated 12 months ago
1// set at Thu May 02 2024 18:00:24 GMT+0000 (Coordinated Universal Time)
2export let vtOpenAPI = "openapi: 3.1.0\ninfo:\n title: Val Town API\n description: |\n The Val Town API provides services to evaluate JavaScript and TypeScript expressions, run vals as APIs, either as functions or Express handlers.\n\n Learn more at [https://docs.val.town](https://docs.val.town)\n version: 1.7.0\nservers:\n - url: https://api.val.town\n description: Val Town API v1\n\ncomponents:\n securitySchemes:\n bearerAuth:\n type: http\n scheme: bearer\n bearerFormat: API Key\n schemas:\n JSON:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n description: \"Can be anything: string, number, array, object, etc., including `null`\"\n Relationship:\n type: string\n enum: [\"received\", \"given\", \"any\"]\n Privacy:\n type: string\n enum: [\"public\", \"unlisted\", \"private\"]\n Author:\n type: object\n properties:\n id:\n description: The user's id\n type: string\n format: uuid\n username:\n description: The user's username\n type: string\n User:\n type: object\n allOf:\n - $ref: \"#/components/schemas/Author\"\n properties:\n bio:\n description: The user's bio\n type:\n - string\n - \"null\"\n profileImageUrl:\n description: The url for the user's profile picture\n type:\n - string\n - \"null\"\n BaseVal:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n name:\n type: string\n code:\n type: string\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n FullVal:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseVal\"\n properties:\n logs:\n type: array\n items: {}\n output:\n type: object\n exported:\n type: object\n error:\n type: object\n readme:\n type: string\n likeCount:\n type: number\n referenceCount:\n type: number\n ValFields:\n type: object\n properties:\n name:\n type: string\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n readme:\n type:\n - string\n - \"null\"\n ValInput:\n type: object\n allOf:\n - $ref: \"#/components/schemas/ValFields\"\n properties:\n code:\n type: string\n PaginatedList:\n type: object\n properties:\n data:\n type: array\n links:\n type: object\n properties:\n self:\n description: The URL of the current page of results\n type: string\n format: uri\n next:\n description: The URL of the next page of results\n type: string\n format: uri\n prev:\n description: The URL of the previous page of results\n type: string\n format: uri\n ValList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseVal\"\n BaseValRef:\n type: object\n properties:\n id:\n description: The id of the val\n type: string\n name:\n description: The name of the val\n type: string\n author:\n $ref: \"#/components/schemas/Author\"\n author_id:\n description: The id of the val's author\n type: string\n deprecated: true\n username:\n description: The username of the val's author\n type: string\n deprecated: true\n ValRef:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseValRef\"\n properties:\n public:\n type: boolean\n deprecated: true\n privacy:\n $ref: \"#/components/schemas/Privacy\"\n version:\n type: integer\n format: int32\n BaseRun:\n type: object\n properties:\n id:\n type: string\n format: uuid\n error: {}\n parentId:\n type: string\n format: uuid\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n val:\n $ref: \"#/components/schemas/ValRef\"\n FullRun:\n type: object\n allOf:\n - $ref: \"#/components/schemas/BaseRun\"\n properties:\n emails:\n type: array\n items: {}\n logs:\n type: array\n items: {}\n returnValue: {}\n args:\n type: array\n items: {}\n RunList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/BaseRun\"\n Comment:\n type: object\n properties:\n id:\n type: string\n format: uuid\n author:\n $ref: \"#/components/schemas/Author\"\n comment:\n description: The contents of the comment\n type: string\n createdAt:\n type: string\n format: date-time\n val:\n $ref: \"#/components/schemas/ValRef\"\n Reference:\n type: object\n properties:\n referencedAt:\n type: string\n format: date-time\n reference:\n $ref: \"#/components/schemas/BaseValRef\"\n dependsOn:\n $ref: \"#/components/schemas/BaseValRef\"\n CommentList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Comment\"\n ReferenceList:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n $ref: \"#/components/schemas/Reference\"\n parameters:\n expression:\n in: path\n name: expression\n required: true\n description: |\n The JavaScript or TypeScript expression to be evaluated.\n This should be a single expression, like a single function\n call, assignment operation, or calculation. If you need\n to execute multiple expressions, wrap them in a function.\n schema:\n type: string\n examples:\n simpleAddition:\n value: \"1+1\"\n summary: Simple addition\n functionCall:\n value: \"@stevekrouse.addOne(@stevekrouse.example1)\"\n summary: Calling a user's val function\n user_id:\n name: user_id\n in: path\n required: true\n description: id of the user\n schema:\n type: string\n format: uuid\n examples:\n stevekrouse:\n value: \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\"\n username:\n name: username\n in: path\n required: true\n description: |\n The username of the val owner, *not* including the `@` symbol.\n schema:\n type: string\n examples:\n stevekrouse:\n value: stevekrouse\n summary: Steve Krouse's username\n val_id:\n name: val_id\n in: path\n required: true\n description: id of the val\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\"\n val_name:\n name: val_name\n in: path\n required: true\n description: The name of the val.\n schema:\n type: string\n examples:\n id:\n value: id\n summary: \"id\"\n description: |\n This val is a function that returns its arguments. It is useful for testing how the API handles the arguments passed to it.\n\n View the val at [https://val.town/v/stevekrouse.id](https://val.town/v/stevekrouse.id)\n version:\n name: version\n in: path\n required: true\n description: val version\n schema:\n type: number\n run_id:\n name: run_id\n in: path\n required: true\n description: id of the log\n schema:\n type: string\n format: uuid\n examples:\n hello:\n value: \"cd0653ac-aede-4d0d-8c8e-21c7ef763eb2\"\n offset:\n name: offset\n in: query\n description: Pagination offset\n schema:\n type: integer\n default: 0\n minimum: 0\n limit:\n name: limit\n in: query\n description: Pagination limit\n schema:\n type: integer\n default: 20\n minimum: 1\n maximum: 100\n comments_since:\n name: since\n in: query\n description: Return comments where `createdAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n comments_until:\n name: until\n in: query\n description: Return comments where `createdAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_since:\n name: since\n in: query\n description: Return references where `referencedAt > since` (non-inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n references_until:\n name: until\n in: query\n description: Return references where `referencedAt <= until` (inclusive)\n schema:\n type: string\n examples:\n isostring:\n $ref: \"#/components/examples/isostring\"\n relationship:\n name: relationship\n in: query\n schema:\n $ref: \"#/components/schemas/Relationship\"\n examples:\n user_stevekrouse:\n value:\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n \"bio\": \"mayor of val town\\nhttps://stevekrouse.com\",\n \"profileImageUrl\": \"https://images.clerk.dev/uploaded/img_2PqHa2Gsy93xQrjh2w78Xu0cChW.jpeg\",\n }\n val_hello:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 0,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n val_hello_v1:\n value:\n {\n \"id\": \"eb4a2ace-b6c8-4393-85e0-4813b3f04e12\",\n \"author\":\n {\n \"id\": \"a0bf3b31-15a5-4d5c-880e-4b1e22c9bc18\",\n \"username\": \"@stevekrouse\",\n },\n \"name\": \"hello\",\n \"code\": 'export let hello = \"Hello World 2\";',\n \"public\": false,\n \"privacy\": \"private\",\n \"version\": 1,\n \"runStartAt\": null,\n \"runEndAt\": null,\n \"logs\": [],\n \"output\": { \"json\": \"Hello World 2\" },\n \"exported\": { \"json\": { \"hello\": \"Hello World 2\" } },\n \"error\": null,\n \"readme\": \"# Hello\",\n \"likeCount\": 0,\n \"referenceCount\": 0,\n }\n isostring:\n value: \"2023-07-26T03:28:00.000Z\"\n summary: ISO String\n responses:\n ExpressionResult:\n description: The returned result of executing the passed expression successfully. The result can be of any JSON type. It will not include any logs that were generated during execution.\n content:\n application/json:\n schema:\n oneOf:\n - type: string\n - type: number\n - type: object\n - type: array\n items: {}\n - type: boolean\n examples:\n simpleAddition:\n value: 2\n summary: Simple addition result\n functionCall:\n value: 42\n summary: Calling a function result\n\nsecurity:\n - bearerAuth: []\n - {}\n\npaths:\n /v1/me:\n get:\n summary: Get profile information for the current user\n tags: [Me]\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"401\":\n description: Unauthorized\n\n /v1/me/likes:\n get:\n summary: Get vals liked by the current user\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/comments:\n get:\n summary: Get comments related to current user, either given or received\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/comments_since\"\n - $ref: \"#/components/parameters/comments_until\"\n - $ref: \"#/components/parameters/relationship\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/CommentList\"\n \"401\":\n description: Unauthorized\n\n /v1/me/references:\n get:\n summary: Returns vals that depend on any of the user's vals\n tags: [Me]\n parameters:\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n - $ref: \"#/components/parameters/references_since\"\n - $ref: \"#/components/parameters/references_until\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ReferenceList\"\n \"401\":\n description: Unauthorized\n\n /v1/vals:\n post:\n summary: Create a new val\n tags: [Vals]\n requestBody:\n description: Code of the new val to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World\";'\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"401\":\n description: Unauthorized\n put:\n summary: Create or update a val by name and code.\n tags: [Vals]\n requestBody:\n description: The JSON to set the val to\n required: true\n content:\n application/json:\n schema:\n type: object\n properties:\n name:\n type: string\n description: Name of the val\n code:\n type: string\n description: Code to run for the val\n required:\n - name\n - code\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/BaseVal\"\n \"401\":\n description: Unauthorized\n \"400\":\n description: Error\n\n /v1/vals/{val_id}:\n get:\n summary: Get val by id\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val not found\n put:\n summary: Update a val's name or privacy\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Fields to be updated.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValFields\"\n examples:\n name_and_privacy:\n value: { \"name\": \"hello\", \"privacy\": \"unlisted\" }\n responses:\n \"204\":\n description: No Content\n \"401\":\n description: Unauthorized\n delete:\n summary: Delete a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n responses:\n \"204\":\n description: No Content\n\n /v1/vals/{val_id}/versions:\n get:\n summary: List versions of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n type: object\n allOf:\n - $ref: \"#/components/schemas/PaginatedList\"\n properties:\n data:\n type: array\n items:\n type: object\n properties:\n val_id:\n type: string\n format: uuid\n description: Unique identifier for the val.\n version:\n type: number\n description: Version number of the val.\n runStartAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n runEndAt:\n type:\n - string\n - \"null\"\n format: date-time\n deprecated: true\n \"404\":\n description: Val not found\n post:\n summary: Create a new version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n requestBody:\n description: Code of the new version to be run.\n required: true\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValInput\"\n examples:\n increment:\n value: { \"code\": 'let hello = \"Hello World 2\";' }\n text/plain:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n text/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n application/javascript:\n schema:\n type: string\n examples:\n increment:\n value: 'let hello = \"Hello World 2\";'\n responses:\n \"201\":\n description: Created\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello_v1\"\n \"404\":\n description: Val not found\n\n /v1/vals/{val_id}/versions/{version}:\n get:\n summary: Get a specific version of a val\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n examples:\n hello:\n $ref: \"#/components/examples/val_hello\"\n \"404\":\n description: Val or version not found\n delete:\n summary: Delete a val version\n tags: [Vals]\n parameters:\n - $ref: \"#/components/parameters/val_id\"\n - $ref: \"#/components/parameters/version\"\n responses:\n \"204\":\n description: No Content\n\n /v1/users/{user_id}/vals:\n get:\n summary: List a user's vals\n tags: [Users]\n parameters:\n - $ref: \"#/components/parameters/user_id\"\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/alias/{username}:\n get:\n summary: Get a user profile information by their username\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/User\"\n examples:\n stevekrouse:\n $ref: \"#/components/examples/user_stevekrouse\"\n \"404\":\n description: Not found\n\n /v1/alias/{username}/{val_name}:\n get:\n summary: Get a val by the author's username and val name\n tags: [Alias]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/FullVal\"\n \"404\":\n description: Not found\n\n /v1/search/vals:\n get:\n summary: Search for vals across the platform\n tags: [Search]\n parameters:\n - name: query\n in: query\n description: Search query\n required: true\n schema:\n type: string\n minLength: 1\n maxLength: 512\n - $ref: \"#/components/parameters/offset\"\n - $ref: \"#/components/parameters/limit\"\n responses:\n \"200\":\n description: OK\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/ValList\"\n\n /v1/eval/{expression}:\n get:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n parameters:\n - $ref: \"#/components/parameters/expression\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/eval:\n post:\n summary: Evaluate a JavaScript or TypeScript expression\n tags: [\"Eval\"]\n description: |\n Evaluates the JavaScript or TypeScript `{expression}` and responds with the returned result. \n\n ### Unauthenticated\n Unauthenticated use will have read-only access to public vals. \n\n ### Authenticated\n Authenticated use will have read access to the authenticated user's private vals and secrets, write access to the authenticated user's vals, and the ability to send the authenticated user emails via `console.email`.\n\n Vals generated via this API will *not* appear in the authenticated user's workspace.\n requestBody:\n description: When used as a POST endpoint, the request body\n must contain the code to be run.\n required: true\n content:\n application/json:\n schema:\n type: object\n required: [\"code\"]\n properties:\n code:\n type: string\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n examples:\n \"Add two numbers\":\n value: { \"code\": \"(a, b) => a + b\", \"args\": [1, 42] }\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n /v1/run/{username}.{val_name}:\n get:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n description: This endpoint runs the specified user's val and returns the output.\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n - in: query\n name: args\n schema:\n type: string\n description: The args query parameter can provide arguments to the given val. The parameter needs to be a JSON-encoded array, in which each item in the array is passed to the val as a function parameter.\n examples:\n name:\n value: '[\"Steve\"]'\n summary: Calling a function with a single string argument\n empty:\n value: \"\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n deprecated: true\n summary: Run a val as an API\n tags: [\"Run\"]\n parameters:\n - $ref: \"#/components/parameters/username\"\n - $ref: \"#/components/parameters/val_name\"\n requestBody:\n required: false\n description: Provide arguments to the given val function by including a post body with your request.\n content:\n application/json:\n schema:\n type: object\n additionalProperties: false\n properties:\n args:\n type: array\n items:\n $ref: \"#/components/schemas/JSON\"\n responses:\n \"200\":\n $ref: \"#/components/responses/ExpressionResult\"\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n\n \"/\":\n servers:\n - url: https://{username}-{val_name}.express.val.run\n description: Val Town API v1\n variables:\n username:\n default: stevekrouse\n val:\n default: expressHTMLExample\n get:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n Unlike the other two APIs, the Express API is specified via subdomain and runs at `https://{username}-{val_name}.express.val.run`.\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n post:\n summary: Run a val as an API (as an Express handler)\n tags: [\"Express\"]\n description: |\n Runs `@{username}.{val_name}` as an Express handler. \n\n `@{username}.{val_name}` must be a function. It is passed the Express [`req`](https://expressjs.com/en/4x/api.html#req) and [`res`](https://expressjs.com/en/4x/api.html#res) objects as its arguments. You can use `req` to pull out request data, and `res` to respond with any valid Express response. Learn more at the [Express docs](https://expressjs.com/en/4x/api.html).\n\n ### Unauthenticated\n Unauthenticated use will only be able to call public vals as Express handlers.\n\n The val will be executed with `{username}`'s permissions (\"API Mode\"), so it will be able to read and write to `{username}`'s public and private vals, secrets, and use `console.email`.\n\n ### Authenticated\n Authenticated use is able to call private vals as Express handlers.\n requestBody:\n description: |\n The request body will be accessible to the val Express handler under the first argument, commonly called `req`, as `req.body`.\n required: false\n content:\n application/json:\n schema:\n $ref: \"#/components/schemas/JSON\"\n examples:\n name:\n value: '{\"name\": \"Steve\"}'\n summary: JSON object as the request body\n responses:\n \"200\":\n description: Function executed successfully\n content:\n \"*/*\":\n schema:\n type: string\n description: The result of the executed function, in any media type\n \"400\":\n description: Bad request or Error thrown executing user code\n \"404\":\n description: Not found\n \"500\":\n description: Internal server error\n";

passkeys_demomain.tsx3 matches

@stevekrouse•Updated 1 year ago
23
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}

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago