Search
aqi
@ari
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast
AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
export async function aqi(interval: Interval) {
const location = "waterford connecticut"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
aoc_2023_11_practical
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
starAt (remap x X) (remap y Y) :-
charAt X Y is "#".
function bigabs(x) {
return x < 0 ? -x : x;
for (const expansionFactor of [2, 10, 100, 1000000]) {
VALLE
@MichaelNollox
VALL-E LLM code generation for vals! Make apps with a frontend, backend, and database. It's a bit of work to get this running, but it's worth it. Fork this val to your own profile. Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in tempValsParentFolderId . If you want to use OpenAI models you need to set the OPENAI_API_KEY env var . If you want to use Anthropic models you need to set the ANTHROPIC_API_KEY env var . Create a Val Town API token , open the browser preview of this val, and use the API token as the password to log in.
HTTP
* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
text: string;
timestamp: number;
export default async function main(req: Request): Promise<Response> {
if (req.method === "GET") {
// Retrieve and return all comments
gitReleaseNotes
@kylem
Github Release Notes from package.json Enter a raw github URL to a package.json, https://raw.githubusercontent.com/username/repo/branch/package.json and get a response of all release notes for all packages from current to latest. Roadmap [ ] GenAI summary [ ] Weekly cron email reports [ ] Send update PRs [ ] Other package managers like PyPi [ ] Formatting/styling [ ] Loading spinner
HTTP
// Function to fetch package info from NPM registry
async function fetchPackageInfo(packageName: string) {
// Function to extract GitHub repo URL from package info
function extractGitHubRepoUrl(packageInfo: any): string | null {
// Function to get the GitHub repository path (owner/repo) from the URL
function getGithubRepoPath(repoUrl: string): string | null {
async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
function compareVersions(version1: string, version2: string): number {
async function getReleaseNotesBetweenVersions(repo: string, currentVersion: string): Promise<GithubRelease[]> {
async function checkNpmUpdates(packageJsonUrl: string): Promise<string> {

retThis
@serna
An interactive, runnable TypeScript val by serna
Script
import { retThat } from "https://esm.town/v/serna/retThat";
export async function retThis() {
return await retThat();
succinctCyanLungfish
@mdalam7294
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import React, { useState } from "https://esm.sh/react@18.2.0";
function WebsiteRanker() {
const [url, setUrl] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<WebsiteRanker />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/rank") {
efficientWhiteBobolink
@deepmojo
@jsxImportSource https://esm.sh/react
HTTP
import React, { useState, useEffect } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function App() {
const [domain, setDomain] = useState("");
const [crawlResults, setCrawlResults] = useState(null);
const root = createRoot(rootElement);
root.render(React.createElement(React.StrictMode, null, React.createElement(App)));
export default async function server(req: Request): Promise<Response> {
const url = new URL(req.url);
if (req.method === "POST" && url.pathname === "/api") {
tanaCalculator
@eagle251
An interactive, runnable TypeScript val by eagle251
Script
import { calculator as calculator2 } from "https://esm.town/v/eagle251/calculator";
export async function tanaCalculator(res, req) {
let operation = `${req.query.operation}`;
let number1 = `${req.query.number1}`;

jsPython
@brettsmith
An interactive, runnable TypeScript val by brettsmith
Script
const { jsPython } = await import("npm:jspython-interpreter");
const script = `
def mapFunction(r, i):
v = r * i
return v
x = [1, 2, 3, 4]
x
.map(mapFunction)
.filter(r => r * r)
.join(",")

nighthawks
@yawnxyz
This is nighthawks an experimental NPC character generator that remembers details about conversations.
Import this into other workflows for now; a UI is coming soon!
Script
const characterModel = new ModelProvider({
id: `${characterName}`,
// for web search / tool use, use openai
provider: 'openai',
model: 'gpt-4o',
// provider: 'groq',

vtOpenAPI
@stevekrouse
// set at Thu May 02 2024 18:00:24 GMT+0000 (Coordinated Universal Time)
Script
// set at Thu May 02 2024 18:00:24 GMT+0000 (Coordinated Universal Time)
export 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";
valle_tmp_58361579707729794716271798593166
@janpaul123
// This val responds to HTTP requests with an HTML page displaying "Hello, world!" with a crazy gradient background
HTTP
// This val responds to HTTP requests with an HTML page displaying "Hello, world!" with a crazy gradient background
export default async function main(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
coffeeHaddock
@satvikrepaka
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",