Search

Results include substring matches and semantically similar vals. Learn more
russbiggs avatar
foo
@russbiggs
An interactive, runnable TypeScript val by russbiggs
Script
export let foo = async (bar) => {
console.email(`This is ${bar}`);
steveb1313 avatar
OfficeJSTest
@steveb1313
An interactive, runnable TypeScript val by steveb1313
Script
export async function OfficeJSTest(
req: express.Request,
res: express.Response,
res.json({ message: "hello" });
gueejla avatar
sillyCSS
@gueejla
Trying out importing CSS into vals from a single definition.
Script
Trying out importing CSS into vals from a single definition.
export const sillyCSS = `
body {
text-align: center;
font-family: cursive;
margin-top: 50px;
input {
font-size:30px;
font-family: cursive;
margin-top: 20px;
dhvanil avatar
val_AIIV7ilXZE
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
tmcw avatar
nhttpExample
@tmcw
nhttp example This uses the tiny nhttp framework with the Val Town Web API . New frameworks like nhttp works really well with our system because they rely on the standard Request & Response objects! Server examples Hono Peko Itty Router Nhttp
HTTP
# nhttp example
This uses the tiny [nhttp framework](https://github.com/nhttp/nhttp) with the Val Town [Web API](https://docs.val.town/api/we
### Server examples
- [Hono](https://www.val.town/v/tmcw.honoExample)
- [Peko](https://www.val.town/v/tmcw.pekoExample)
- [Itty Router](https://www.val.town/v/tmcw.ittyRouterExample)
export const nhttpExample = async (request) => {
const { nhttp } = await import("npm:nhttp-land@1");
const app = nhttp();
app.get("/", () => {
tmcw avatar
sendFiveHundred
@tmcw
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Script
/** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqu
export let sendFiveHundred = (req, res) => {
res.send("Five hundred", 500);
yawnxyz avatar
wahoo
@yawnxyz
An interactive, runnable TypeScript val by yawnxyz
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json( {message: 'hello!!'})
chini5ko avatar
tldraw_computer_example
@chini5ko
tldraw computer custom endpoint example This val is an example custom endpoint for tldraw computer 's data component. Usage To use this val with tldraw.computer, follow these steps: Fork this Val. Click the Copy endpoint button on your new Val. Open a project on tldraw.computer Create a Data component in your tldraw computer project In the Source dropdown, select Custom and the POST method Paste the endpoint into Data component's the HTTP Endpoint input. Run the component. To see the output, connect the Data component to a Text component. How it works In tldraw computer, you can configure a Data component to use a custom HTTP endpoint as its data source. You can also configure the request method, either GET or POST. If a Data component's request method is POST, then when the component next updates, it will send a POST request to the endpoint. The request's body will contain an array of the Data objects that the component had received as inputs. If the request method if GET, then the component will only make the request—its body will be empty. In both cases, the component will expect back a response that includes an array of Data objects these objects will be passed along as the data component's outputs. The endpoint (your forked version of this Val) can do whatever it likes between the request and response, but the response must include data in the correct format. If the format is wrong, the computer app will create a text data object instead that includes the response as plain text. Support If you're running into any difficulties, check out the #tldraw-computer channel on the tldraw discord.
HTTP
# tldraw computer custom endpoint example
This val is an example custom endpoint for [tldraw computer](tldraw.computer)'s data component.
### Usage
To use this val with tldraw.computer, follow these steps:
1. Fork this Val.
2. Click the **Copy endpoint** button on your new Val.
// This endpoint accepts and returns data.
type BooleanData = {
type: "boolean";
text: "true" | "false" | "maybe";
ming avatar
postWebhook
@ming
An interactive, runnable TypeScript val by ming
Script
export let postWebhook = (req, res) => {};
u avatar
schema
@u
An interactive, runnable TypeScript val by u
Script
export function schema(req, res) {
dhvanil avatar
val_4P4JYmfbXg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
begoon avatar
ghdb
@begoon
This val implements a simple key/value database with GitHub, in a CRUD way. The key is a file path within a repository. The value is the file content. The val needs a GitHub token to access the GitHub API, the account name and the repository name. Also, the val needs GHDB_API_KEY variable. This value defines the exptected value of the GHDB_API_KEY header to allow access to the endpoints. Endpoints: GET /data/path/to/file.ext - read file GET /raw/path/to/file.ext - read file from GitHub CDN (10 times faster) DELETE /data/path/to/file.ext - delete file POST /data/path/to/file.ext - create file PUT /data/path/to/file.ext - update/commit file
HTTP
This val implements a simple key/value database with GitHub, in a CRUD way.
The key is a file path within a repository. The value is the file content.
The val needs a GitHub token to access the GitHub API, the account name
and the repository name.
Also, the val needs GHDB_API_KEY variable. This value defines the exptected
value of the GHDB_API_KEY header to allow access to the endpoints.
consola.options.formatOptions.columns = 0;
consola.options.formatOptions.compact = false;
export type Data = {
content: string | Uint8Array;
patmood avatar
home
@patmood
An interactive, runnable TypeScript val by patmood
Script
export let home = (req: express.Request, res: express.Response) => {
res.send("<h1>hi</h1>");
stevekrouse avatar
edit_redirect_example
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
import { Hono } from "npm:hono@3";
const app = new Hono();
app.get("/", (c) => c.text("Hello world!"));
app.get("/edit", (c) => editRedirect());
export default app.fetch;
dhvanil avatar
val_0nx0n0guGp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });