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/<author>/<name>.<extension>[?v=<version>]
To see the code of this val, use https://pomdtr-raw.web.val.run/pomdtr/raw.ts
Examples
Fetching the val code
$ curl https://pomdtr-raw.web.val.run/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/pomdtr/privateVal.ts"
Fetching the val README
$ curl https://pomdtr-raw.web.val.run/pomdtr/add.md
Getting an image
$ curl https://pomdtr-raw.web.val.run/pomdtr/add.png
Fetching a specific version of a val
$ curl https://pomdtr-raw.web.val.run/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/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/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/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
Preview and edit blobs
Usage:
Create valimport blobEditor from "https://esm.town/v/pomdtr/blob_editor"
export default blobEditor("article.md")
You can easily protect your val behind @pomdtr/password_auth or @pomdtr/email_auth
jsr2gh
Redirect to jsr package's GitHub repository page, like vladimyr-jsr2gh.web.val.run/@luca/flag
Usage
https://vladimyr-jsr2gh.web.val.run/<scope>/<name>
Example
Use readme as website
Usage
See this val http endpoint as an example: https://pomdtr-article.web.val.run
Cli Vals
Cli vals are a new type of val (same as http, email, cron and script vals). A cli val must use a function without args as it's default export.
The function body will run on the user device using deno. An error message will be shown if deno is not installed.
export default function() {
if (Deno.args.length == 0) {
console.error("<name> arg is required!");
Deno.exit(1);
}
console.log(`Hey ${Deno.args[0]}!`);
}
Fork @pomdtr/example_cli to get started.
Of course, you can use a cli framework to parse arguments (ex: cliffy).
Running a cli val
Go to https://pomdtr-cli.web.val.run/v/<author>/<name>[?v=<version>]
to get a runnable script for your val.
You can pipe the script to a shell to test it
curl 'https://pomdtr-cli.web.val.run/v/pomdtr/cli_example' | sh -s Steve
Hello Steve!
Or save it to your $PATH
.
# save the script to the ~/.local/bin folder
curl 'https://pomdtr-cli.web.val.run/v/pomdtr/cli_example' > ~/.local/bin/cli_example
# make the script executable
chmod +x ~/.local/bin/cli_example
# run the installed val
cli_example Steve
Allowing cli vals to access private resources
Cli vals run on your device, so by default they can only access public/unlisted vals.
You can set the DENO_AUTH_TOKENS env var in your shell config to allow deno to import private vals.
export DENO_AUTH_TOKENS=<your-token>@esm.town
Cli vals don't have access to val town tokens. Instead of trying to replicate your valtown secrets locally, you can configure your cli vals to call your http endpoints using fetch
.
My Val Town Wish List
Some things I'd love to see come to val town (some of these are already on the way according to the team)
- Editing a val's readme through the API
- A command bar (something like paco's cmdk would be dope)
- The ability or programmatically respond to events (like a val being run) right within Val Town
- User defined templates usable right in the val creation flow
- Public folders / ability to add readmes to folders
- Dynamic folders (ala Tana's search nodes)
- Custom val metadata (such as tags)
- A more fully featured markdown editor for readmes
Usage:
Create valimport blobEditor from "https://esm.town/v/pomdtr/blob_editor"
export default blobEditor("article.md")
You can easily protect your val behind @pomdtr/passwordAuth or @pomdtr/emailAuth
Render Gist
Usage
Go to a gist page, and replace gist.github.com
by pomdtr-renderGist.web.val.run
Example: https://pomdtr-renderGist.web.val.run/probonopd/9feb7c20257af5dd915e3a9f2d1f2277
export const title = "mdx"
{title}
Usage
Create valimport { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { mdx } from "https://esm.town/v/pomdtr/mdx";
const { author, name } = extractValInfo(import.meta.url);
export default mdx(author, name);
Val Shot
Usage
https://pomdtr-valshot.web.val.run/v/<author>/<val>