Search
html
@neverstew
@jsxImportSource npm:preact
Script
/** @jsxImportSource npm:preact */
import type { VNode } from "npm:preact";
import { render } from "npm:preact-render-to-string";
export const html = (html: VNode) =>
BlogChatbotServer
@weaverwhale
// This approach will create a chatbot using OpenAI's SDK with access to a blog's content stored in a JSON.
HTTP
// This approach will create a chatbot using OpenAI's SDK with access to a blog's content stored in a JSON.
// We'll use Hono for routing, OpenAI for the chatbot, and stream the responses to the client.
// The blog content will be stored as JSON and used as a tool in the chatbot's chain.
import { Hono } from "https://esm.sh/hono";
linkInBioTemplate
@ttodosi
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
FanficSearcherWebsite
@willthereader
// first stable version is 9 and the link is https://www.val.town/v/willthereader/FanficSearcherWebsite?v=9
HTTP
<script>
console.log("Initializing Algolia search with App ID:", "${appId}");
const searchClient = algoliasearch("${appId}", "${apiKey}");
const search = instantsearch({
indexName: "NewGameNewLife",
searchClient,
debug: true,
search.addWidgets([
fets
@pomdtr
Fets Example A openapi JSON spec is available at https://pomdtr-fets.web.val.run/openapi.json . You can access a fully typed client with a single import: import { client } from "https://esm.town/v/pomdtr/fets";
const resp = await client["/greetings"].get();
const res = await resp.json();
console.log(res.message);
HTTP (deprecated)
A openapi JSON spec is available at <https://pomdtr-fets.web.val.run/openapi.json>.
You can access a fully typed client with a single import:
```typescript
import { client } from "https://esm.town/v/pomdtr/fets";
const resp = await client["/greetings"].get();
const res = await resp.json();
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
import { createClient, createRouter, Response } from "npm:fets@0.7.1";
export const router = createRouter({
const val = extractValInfo(import.meta.url);
export const client = createClient<typeof router>({
fetchFn: router.fetch,
p5
@moe
P5 sketch Easily turn a p5.js sketch into a val. See https://www.val.town/v/saolsen/p5_sketch for an example. Usage Make a p5 sketch, you can import the p5 types to make it easier. import type * as p5 from "npm:@types/p5"; Export any "global" p5 functions. These are functions like setup and draw that p5 will call. Set the val type to http and default export the result of sketch , passing in import.meta.url . A full example looks like this. import type * as p5 from "npm:@types/p5";
export function setup() {
createCanvas(400, 400);
}
export function draw() {
if (mouseIsPressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}
import { sketch } from "https://esm.town/v/saolsen/p5";
export default sketch(import.meta.url); How it works The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default sketch export) so you can't call any Deno functions, environment variables, or other server side apis.
Script
## How it works
The sketch function returns an http handler that sets up a basic page with p5.js added. It then imports your module from the browser and wires up all the exports so p5.js can see them. All the code in your val will run in the browser (except for the default `sketch` export) so you can't call any Deno functions, environment variables, or other server side apis.
emailGithubReactions
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export const emailGithubReactions = async () => {
const username = "stevekrouse";
event.type === "IssueCommentEvent" && event.payload.action === "created"
const recentReactions = [];
for (const comment of comments) {
for (
const reaction of await fetchJSON(
comment.payload.comment.reactions.url,
if (msAgo(15 * msMinute)) {
recentReactions.push(
`${reaction.user.login} reacted with ${reaction.content} to ${comment.payload.comment.html_url}`,
if (recentReactions.length > 0) {
await email({
text: recentReactions.join("\n"),
subject: "new github reactions!",
generateEmbeddings
@thomasatflexos
An interactive, runnable TypeScript val by thomasatflexos
Script
const { OpenAIEmbeddings } = await import("npm:langchain/embeddings");
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
"npm:langchain/document_loaders/web/cheerio"
const client = createClient(
process.env.supabaseURL,
openAIApiKey: process.env.OPEN_API_KEY,
client,
tableName: "documents",
forbetHeader
@nmsilva
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
const ForbetHeader = () => {
return (
bigLeagueMe
@nuklearfiziks
Big League yourself! WARNING, this will unfollow every user you follow!
Script
// Ex: user.bsky.social
const handle = params.HANDLE || "";
// YOUR bluesky password, or preferably an App Password (found in your client settings)
// Ex: abcd-1234-efgh-5678
const password = params.PASS || "";
useTheLibraryThatNeedsValidation
@maxm
An interactive, runnable TypeScript val by maxm
Script
import { newClient } from "https://esm.town/v/maxm/libraryThatNeedsValidation";
try {
let client = await newClient("maxm", "wrong");
} catch (err) {
console.log(err);
let client = await newClient("maxm", "password");
console.log("logged in and validated", client.getUsername());
myReactComponent
@liamdanielduffy
// assumes React is in scope, and returns a valid HTML script string for rendering a React Component
Script
// assumes React is in scope, and returns a valid HTML script string for rendering a React Component
export function myReactComponent() {
return `
const Example = () => {
return React.createElement("div", null, "Hello, React!");
ReactDOM.render(React.createElement(Example), document.getElementById("root"));
redirect
@thomasatflexos
This is a handler for when Notion redirects during OAuth 2.0 workflow
Express
// This endpoint uses Basic Authentication which requires a 64-encoded token
const token = process.env.OAUTH_CLIENT_ID + ":" +
process.env.OAUTH_CLIENT_SECRET;
const response = await fetch("https://api.notion.com/v1/oauth/token", {
// Using supabase to store out information
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
const supabase = createClient(
process.env.supabaseURL,