stevekrouse avatar
json_viewer
@stevekrouse
Script
Inspector to browser json data in HTTP vals Example: https://val.town/v/stevekrouse/weatherDescription Thanks @mmcgrana (https://markmcgranaghan.com/) for the idea!
petermillspaugh avatar
dailySubscriptionStats
@petermillspaugh
Cron
Val Town email subscriptions: daily stats Cousin Val to @petermillspaugh/emailSubscription for emailing yourself daily subscriber stats.
stevekrouse avatar
plotHTMLExample
@stevekrouse
HTTP
Observable Plot Vanilla HTML Example Code from https://observablehq.com/plot/getting-started#plot-in-vanilla-html
stevekrouse avatar
auth_middleware
@stevekrouse
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). 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.
stevekrouse avatar
formOld
@stevekrouse
Script
// Forked from @andreterron.valtown_forms_test
postpostscript avatar
htmlAsync
@postpostscript
Script
htmlAsync: async fork of @postpostscript/html supporting Promises as replacements Examples import { delay } from "https://deno.land/x/delay@v0.2.0/mod.ts"; import { html, htmlResponseAsync } from "https://esm.town/v/postpostscript/htmlAsync"; export default function(req: Request) { return htmlResponseAsync` ${(async () => { await delay(1000); return `<script>console.log("sanitized")</script>`; })()} ${(async () => { await delay(1000); return html`<script>console.log("unsanitized")</script>`; })()} `; } Tests: @postpostscript/htmlAsyncTest
pomdtr avatar
page
@pomdtr
HTTP
Render a val readme Inspired by github pages. Use https://pomdtr-page.web.val.run/v/<author>/<name> Example You can see this val readme at https://pomdtr-page.web.val.run/v/pomdtr/readme
pomdtr avatar
raw
@pomdtr
HTTP
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
ninja_keys
@pomdtr
HTTP
GET https://pomdtr-ninja_keys.web.val.run
stevekrouse avatar
pexelsExample
@stevekrouse
HTTP
An interactive, runnable TypeScript val by stevekrouse
hlobil avatar
untitled_lavenderMite
@hlobil
HTTP
SQLite Admin This is a lightweight SQLite Admin interface to view and debug your SQLite data. It's currently super limited (no pagination, editing data, data-type specific viewers), and is just a couple dozens lines of code over a couple different vals. Forks encouraged! Just comment on the val if you add any features that you want to share. To use it on your own Val Town SQLite database, fork it to your account. It uses basic authentication with your Val Town API Token as the password (leave the username field blank).
stevekrouse avatar
untitled_indigoNightingale
@stevekrouse
HTTP
Blob Admin This is a lightweight Blob Admin interface to view and debug your Blob data. To use it on your own Val Town Blob Storage, fork it to your account. It uses basic authentication with your Val Town API Token as the password (leave the username field blank). TODO [ ] /new - render a page to write a new blob key and value [ ] or new blob by file upload [ ] /edit/:blob - render a page to edit a blob (prefilled with the existing content) [ ] json validation when the existing content is json [ ] checkbox to disable that [ ] /delete/:blob - delete a blob and render success
kamek avatar
password_auth
@kamek
Script
Password Auth Middleware Protect your vals behind a password. Use session cookies to persist authentication. Demo See @pomdtr/password_auth_test Usage If you want to use an api token to authenticate: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth"; export default passwordAuth(() => { return new Response("OK"); }); Or if you prefer to use a string: import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth"; export default passwordAuth(() => { return new Response("OK"); }, { password: Deno.env.get("VAL_PASSWORD") }); You can also set multiple ones import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth"; export default passwordAuth(() => { return new Response("OK"); }, { password: [Deno.env.get("VAL_PASSWORD"), Deno.env.get("STEVE_PASSWORD")] }); Note that authenticating using your api token remain an option even after setting a password. TODO [x] allow to authenticate using a val town token [ ] add a way to send an email to ask a password from the val owner [ ] automatically extend the session [ ] automatically remove expired sessions FAQ How to sign out ? Navigate to <your-site>/signout .
stevekrouse avatar
http_client
@stevekrouse
HTTP
HTTP Client Attach a postman-like http client to your vals, with bookmarks and history support Usage Wrap your http handler in an the httpClient middleware. import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }) Go to https://<author>-<name>.web.val.run/http-client to view the http client UI. Adding bookmarks You might want to bookmark some requests you need often. You can do it by passing a bookmark list as a middleware option: import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }, { bookmarks: [ { "label": "Dummy Request", "request": new Request("https://dummyjson.com/products") } ]}) Customizing the client path import {httpClient} from "https://esm.town/v/pomdtr/http_client" export default httpClient((req) => { return new Response("Hello World!") }, { path: "/" // show the http client on the website root }) TODO [ ] fix syntax highlighting on successive request [ ] allow to prefill the initial request
adamwiggins avatar
renderFormAndSaveData
@adamwiggins
HTTP
Render form and save data This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data. Fork this val to customize it and use it on your account.
janpaul123 avatar
valle_tmp_471598988784462057650343979850462
@janpaul123
HTTP
// This demo showcases a sparkline SVG and an animated cat GIF crawling around the screen.
v5
October 23, 2023