pomdtr
I mainly enjoy building dev tools:
- VS Code integration: https://github.com/pomdtr/valtown-vscode
- CLI: https://github.com/pomdtr/vt
Public vals
317
pomdtr
notebook
HTTP
Notebook Val This val automatically serves the codeblock it contains. Each codeblock is augmented with a set of properties ```html { name: "index.html" }
<h1>Hello world</h1>
``` Properties follow JSON5 syntax . Currently only a name property is supported. Files Entrypoint <html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Page Title</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
<link rel="icon" href="https://fav.farm/📔" />
<script src='main.js'></script>
</head>
<body>
<h1>This whole val code is extracted from a README!</h1>
<a href="https://www.val.town/v/pomdtr/notebook">View Val</a>
</body>
</html> Styling body {
background-color: white;
}
h1 {
color: red;
} Script console.log("Hi from the readme")
1
pomdtr
auth_middleware
Script
Authentication middleware Guards your public http vals behind a login page. This val use a json web token stored as an http-only cookie to persist authentication. Usage Set an AUTH_SECRET_KEY env variable (used to sign/verify jwt tokens) to a random string . Then use an API token to authenticate. import { auth } from "https://esm.town/v/pomdtr/auth_middleware";
async function handler(req: Request): Promise<Response> {
return new Response("You are authenticated!");
}
export default auth(handler); See @pomdtr/test_auth for an example ⚠️ Make sure to only provides your api token to vals you trust (i.e. your own), as it gives access to your whole account.
1
pomdtr
sql
Script
SQL Template Tag Port of blakeembrey/sql-template-tag for usage in val.town. Usage import { sqlite } from "https://esm.town/v/std/sqlite"
import { sql, zip } from "https://esm.town/v/pomdtr/sql"
const query = sql`SELECT * FROM books WHERE author = ${author}`;
console.log(query.sql) // => "SELECT * FROM books WHERE author = ?"
console.log(query.args) // => [author]
const res = await sqlite.execute(query)
console.table(zip(res)) For advanced usage (ex: nesting queries), refer to the project readme .
6
pomdtr
fets
HTTP
Fets Example A openapi JSON spec is available at https://pomdtr-fets.web.val.run/openapi.json . You can access a fully typed client with a single import: import { client } from "https://esm.town/v/pomdtr/fets";
const resp = await client["/greetings"].get();
const res = await resp.json();
console.log(res.message);
0
pomdtr
static
HTTP
Static Vals Serve static content from val.town Usage First, fork this val to get your own http endpoint. Then create a val that uses a string as it's default export, or a single string export. The val must be either public or unlisted . export default `<static content>` You can then fetch the exported string from outside val.town using: curl 'https://<owner>-static.web.val.run/<val>.<extension>' The Content-Type will be dynamically set depending on the provided extension. Example https://pomdtr-static.web.val.run/val_town_readme_style.css Val Link
6