vladimyr-piperesponse_example2.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { InjectCodeOnValTownStream } from "https://esm.town/v/andreterron/InjectCodeOnValTownStream?v=4";
import { InjectHTMLElementStream } from "https://esm.town/v/andreterron/InjectHTMLElementStream?v=9";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=26";
import { MyFooter as createMyFooter } from "https://esm.town/v/vladimyr/MyFooter";
import { createWrappedHandler, pipeResponse } from "https://esm.town/v/vladimyr/pipeResponse";
const { author, name } = extractValInfo(import.meta.url);
class InjectTestElementStream extends InjectHTMLElementStream {
constructor() {
super("<p>more testing</p><p>second paragraph</p>");
}
}
const footer = (await createMyFooter()).toString();
async function serveHtml(req: Request): Promise<Response> {
return new Response(
`
<html>
<head>
<title>test pipeResponse</title>
</head>
<body>
<p>just testing stuff</p>
</body>
</html>
`,
{ headers: { "content-type": "text/html" } },
);
}
export default createWrappedHandler(
serveHtml,
new InjectCodeOnValTownStream({ val: { handle: author, name: name } }),
new InjectTestElementStream(),
new InjectHTMLElementStream(footer),
);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v2
March 8, 2024