Avatar

pomdtr

I mainly enjoy tinkering with the val.town api: - VS Code integration: https://github.com/pomdtr/valtown-vscode - CLI: https://github.com/pomdtr/vt
Joined June 14, 2023
Likes
108
neverstew avatar
thisValUrl
@neverstew
Script
This Val URL Returns the URL of the val that calls this function. See https://www.val.town/v/neverstew.thisValUrlExample
tmcw avatar
streamExample
@tmcw
Script
Response with ReadableStream example Demonstrates our ability to handle streaming responses. We do, in practice, read the streams and then return the response - basically buffering - but with the support for the Response object we include the option to pass a ReadableStream instance as the first argument. Note that it's required that the ReadableStream returns Uint8Array items.
maas avatar
importGists
@maas
Script
Imports Gists to Val Town Import your TypeScript and JavaScript to Val Town Authentication This function requires two keys: one from Github to get your gists, and one from Val Town to make the vals in your account: Github token: https://github.com/settings/tokens Val Town key: https://www.val.town/settings/api Usage You can use this function by calling it and passing your keys like so: @maas.importGists({ githubToken: @me.secrets.githubGists, valTownKey: @me.secrets.valtown, }); Example usage: https://www.val.town/v/maas.untitled_harlequinCrawdad
pomdtr avatar
run
@pomdtr
HTTP (deprecated)
Augmented run api This val is a wrapper on top of the val.town run api, improving it with additional features: basic auth content-type header in response based on url file extension Usage Custom Content-Type The content-type will be inferred from the filename using the mime-types library. If you use a .html extension, the response will be interpreted as text/html ~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html' HTTP/1.1 200 OK ... Content-Type: text/html; charset=utf-8 ... Hello, World! If you switch the extension to .txt , the content-type header switch to text/raw . ~ $ curl -v 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.txt' HTTP/1.1 200 OK ... Content-Type: text/plain; charset=utf-8 ... Hello, World! Passing arguments The request is proxyed to the run api, so you can pass args to your vals via query params or body. See the run api docs for more details. ~ $ curl -X POST -d '{"args": ["pomdtr"]}' 'https://pomdtr-run.web.val.run/pomdtr/helloWorld.html' ... < content-type: text/html; charset=utf-8 ... Hello, pomdtr! Basic Authentication Just add your val town token as the username: curl 'https://<val-token>@pomdtr-run.web.val.run/pomdtr/privateVal.txt'
stevekrouse avatar
xeval
@stevekrouse
HTTP (deprecated)
An interactive, runnable TypeScript val by stevekrouse
pomdtr avatar
prettifyTS
@pomdtr
Script
Prettify Typescript code const pretty = await @pomdtr.prettifyTS("const hello='Hello world'")
pomdtr avatar
valtownOpenAPI
@pomdtr
HTTP (deprecated)
Val Town Typescript Spec This val return an up-to-date typescript version of the val.town openapi spec for usage with a feTS client. Usage Deno script import { createClient, type NormalizeOAS } from "npm:fets"; import openapi from "https://pomdtr-valtownOpenAPI.web.val.run/openapi.ts"; export const client = createClient<NormalizeOAS<typeof openapi>>({ endpoint: openapi.servers[0].url, });
pomdtr avatar
extractValArgs
@pomdtr
Script
Extract Args from a val await @pomdtr.extractValArgs("pomdtr.extractValArgs") // [{ "name": "val", "type": "string" }] Why ? Just an example of doing some static analysis. Using this approach to generate a json schema of a val input would be nice.
pomdtr avatar
raw
@pomdtr
HTTP (deprecated)
Fetch the source of a val This val was created before the introduction of https://esm.town Usage curl https://pomdtr-raw.web.val.run/v/<author>/<name>.<extension>[?v=<version>] To see the code of this val, use https://pomdtr-raw.web.val.run/v/pomdtr/raw.ts Examples Fetching the val code $ curl https://pomdtr-raw.web.val.run/v/pomdtr/add.tsx You can also use js , jsx and ts extension (only the content-type change, there is no transpilation). Fetching private val Pass an api token as an username $ curl "https://<token>@pomdtr-raw.web.val.run/v/pomdtr/privateVal.ts" Fetching the val README $ curl https://pomdtr-raw.web.val.run/v/pomdtr/add.md Getting an image $ curl https://pomdtr-raw.web.val.run/v/pomdtr/add.png Fetching a specific version of a val $ curl https://pomdtr-raw.web.val.run/v/pomdtr/raw.ts?v=66 You need to be authenticated to use this method. Fetching the val metadata $ curl https://pomdtr-raw.web.val.run/v/pomdtr/add.json Running vals locally using Deno Create a new val.ts file referencing the @pomdtr.add import { add } from "https://pomdtr-raw.web.val.run/v/pomdtr/add.ts"; console.log(add(1, 2)); then use deno run $ deno run ./val.ts 3 If you val accept a request and return a response, you can pass it to Deno.Serve to run it locally! import {raw} from "https://pomdtr-raw.web.val.run/v/pomdtr/raw.ts"; Deno.serve(raw); If your val is private, you can set the DENO_AUTH_TOKENS env. DENO_AUTH_TOKENS=<val-town-token>@pomdtr-raw.web.val.run deno run val.ts
pomdtr avatar
fetchValTownAPI
@pomdtr
Script
Fetch data from the val town api Usage Create an helper val const valtownApi = (path: string, options?: RequestInit) => @pomdtr.fetchValTownAPI( @me.secrets.apiToken, path, options, ); Then use it in any of your val @me.valtownApi("/alias/pomdtr")
pomdtr avatar
telegram
@pomdtr
Script
Send yourself a Telegram message Inspired by console.email , this val lets you send yourself a Telegram message via the valtown_bot from any of your vals @me.telegram("hi to me on telegram!") Installation 1. Start a conversation with valtown_bot Click here: https://t.me/valtown_bot 2. Copy your Secret 3. Save in your secrets under telegramSecret 4. Fork this val & run it Save your own private version of a telegram function to your account by forking this val: https://www.val.town/v/pomdtr.telegram 5. Send a test message! await @me.telegram("hi to me on telegram!") PS: the bot code is available here
stevekrouse avatar
telegram
@stevekrouse
Script
Forked from pomdtr/telegram
easrng avatar
button
@easrng
HTTP (deprecated)
An interactive, runnable TypeScript val by easrng
Next