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
devtools
Script
Devtools shortcuts Add useful shortcuts to a val website. Usage /_edit -> go to the val editor /_raw -> view val source /_logs -> view val logs Example import { devtools } from "https://esm.town/v/pomdtr/devtools";
export default devtools((_req: Request) => {
return new Response("hello world");
});
4
pomdtr
serve_readme
Script
Serve Readme Usage import codeOnValTown from "https://esm.town/v/andreterron/codeOnValTown?v=50";
import { serveReadme } from "https://esm.town/v/pomdtr/serve_readme";
const val = extractValInfo(import.meta.url);
export default serveReadme({
val,
title: "Code Search is Easy",
}); Example @pomdtr/code_search_is_easy (rendered at https://code-search-is-easy.pomdtr.me )
0
Updated: December 11, 2023