Vals using hono
Description from the NPM package:
Web framework built on Web Standards
pomdtr
lastloginHono
Script
See @pomdtr/lastlogin for more informations about the middleware Example /** @jsxImportSource npm:hono@3/jsx */
import { lastlogin } from "https://esm.town/v/pomdtr/lastloginHono";
import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail"
import { Hono } from "npm:hono";
const app = new Hono();
const lastloginMiddleware = lastlogin({
verifyEmail: verifyUserEmail
});
// required for the auth pages to work
app.use("/auth/*", lastloginMiddleware);
// this page is public
app.get("/", async (c) => {
return c.html(
<div>
There is a secret message for you if you{" "}<a href="/secret">login</a>
</div>,
);
});
// this page requires the user to signup
app.get("/secret", lastloginMiddleware, async (c) => {
const email = c.req.header("X-User-Email");
return c.html(
<div>
I think {email} is a really silly email address, actually.
</div>,
);
});
export default app.fetch;
1
pomdtr
freeformServer
HTTP
Freeform Brings a taste of Observable to Val Town. This val was adapted from @tmcw obsidian plugin . Instead of using the display function, this port use export default . https://pomdtr-freeformServer.web.val.run/v/<author>/<name> or https://freeform.pomdtr.me/v/<author>/<name> Examples Bar Chart ( View Source )
1
yawnxyz
semanticSearch
Script
In-memory semantic search; load it up with valtown KV. This is a "dumb" version of vector search, for prototyping RAG responses and UIs — with both regular search (w/ Lunr) and vector search (with OpenAI embeddings + cosine similarity) Usage: import { semanticSearch } from "https://esm.town/v/yawnxyz/semanticSearch";
const documents = [
{ id: 1, content: 'cats dogs' },
{ id: 2, content: 'elephants giraffes lions tigers' },
{ id: 3, content: 'edam camembert cheddar' }
];
async function runExample() {
// Add documents to the semantic search instance
await semanticSearch.addDocuments(documents);
const results = await semanticSearch.search('animals', 0, 3);
console.log('Top 3 search results for "animals":');
console.log(results);
}
runExample();
0