Likes
94
saolsen
display_mermaid
Script
Display Mermaid Takes a mermaid document (as a string) and returns an http handler that renders it. Example https://www.val.town/v/saolsen/display_mermaid_example import { displayMermaid } from "https://esm.town/v/saolsen/display_mermaid";
const mermaid = `
sequenceDiagram
Alice->>John: Hello John, how are you?
John-->>Alice: Great!
Alice-)John: See you later!
`;
export default displayMermaid(mermaid);
1
pomdtr
http_client
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!")
}) The http client will be shown on the root. 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: "/http-client"
}) TODO [ ] fix syntax highlighting on successive request [ ] allow to prefill the initial request
7
tmcw
httpMockingExample
HTTP
HTTP Val Mocking example This is an example of mocking an HTTP val. Let's say that you're developing a val that responds to a POST request. That's tricky to debug and develop in the Browser preview tab, which just shows a GET request. But you can do it, because with web-standard Request & Response objects, requests and responses are values, and we can create those values ourselves.
1
easrng
upgradeExpress
Script
upgradeExpress Upgrade Express vals to the Web API without breaking existing consumers How it works upgradeExpress wraps a Web handler into a function that works as normal when called by the Web API, and redirects to the Web API when called by the Express API. Example I don't have an example for this per se but I used it to upgrade @easrng/button.
2