Search

Results include substring matches and semantically similar vals. Learn more
webup avatar
pipeSampleLLMRetrieverConversation
@webup
An interactive, runnable TypeScript val by webup
Script
export const pipeSampleLLMRetrieverConversation = (async () => {
const { PromptTemplate } = await import("npm:langchain/prompts");
const { RunnableSequence, RunnablePassthrough } = await import(
"npm:langchain/schema/runnable"
const { StringOutputParser } = await import(
"npm:langchain/schema/output_parser"
const { Document } = await import("npm:langchain/document");
const modelBuilder = await getModelBuilder();
const model = await modelBuilder();
const docs = await getSampleDocuments();
pomdtr avatar
tealRattlesnake
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
const app = new Hono();
app.get("/", (c) => {
return streamText(c, async (stream) => {
// Write a text with a new line ('\n').
await stream.writeln("Hello");
// Wait 1 second.
await stream.sleep(1000);
// Write a text without a new line.
await stream.write(`Hono!`);
export default app.fetch;
pressjeremy avatar
isMyWebsiteDown
@pressjeremy
An interactive, runnable TypeScript val by pressjeremy
Script
export default async () => {
console.log("hi");
const URL = "https://google.com";
const [date, time] = new Date().toISOString().split("T");
let ok = true;
let reason: string;
try {
const res = await fetch(URL);
if (res.status !== 200) {
reason = `(status code: ${res.status})`;
nbbaier avatar
servePDF
@nbbaier
https://nbbaier-servePDF.web.val.run to view the PDF in browser https://nbbaier-servePDF.web.val.run/download to download the PDF
HTTP
- [https://nbbaier-servePDF.web.val.run](https://nbbaier-servePDF.web.val.run) to view the PDF in browser
- [https://nbbaier-servePDF.web.val.run/download](https://nbbaier-servePDF.web.val.run/download) to download the PDF
const pdfDoc = await PDFDocument.create();
const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman);
const fontSize = 30;
const page = pdfDoc.addPage();
const { width, height } = page.getSize();
page.drawText("Creating PDFs in JavaScript is awesome!", {
x: 50,
y: height - 4 * fontSize,
yawnxyz avatar
luciaValtownSqlite
@yawnxyz
A reorganization of: https://www.val.town/v/stevekrouse/lucia_adapter https://esm.town/v/stevekrouse/lucia_adapter_base
Script
A reorganization of:
https://www.val.town/v/stevekrouse/lucia_adapter
https://esm.town/v/stevekrouse/lucia_adapter_base
Adapter,
DatabaseSession,
DatabaseUser,
RegisteredDatabaseSessionAttributes,
RegisteredDatabaseUserAttributes,
} from "npm:lucia";
export interface TableNames {
simply_say_m avatar
getActivityAndGiphy
@simply_say_m
An interactive, runnable TypeScript val by simply_say_m
Express (deprecated)
export let getActivityAndGiphy =
(async (req: express.Request, res: express.Response) => {
const activity = await boredActivities();
const fetchGiphy = await fetchGiphy2(activity);
const { url } =
fetchGiphy[Math.floor(Math.random() * 10)].images.downsized_large;
return res.send(
`<div style='min-height:100vh; width: 100vw; margin:0; background: radial-gradient(circle, rgba(251,159,63,1) 54%, rgba
<section style='display: flex; flex-direction: column; align-items: center;max-width: 980px; margin: 0 auto;'>
<h1 style='color: orangered; font-family: Palatino; font-size: 3rem; text-align: center;'> You are bored? Maybe:</h1>
cufaoil avatar
aquamarineShrimp
@cufaoil
An interactive, runnable TypeScript val by cufaoil
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json({ address: "http://192.168.50.40:8080/event" });
parweb avatar
elysia
@parweb
Elysia example This is how you can use Elysia with Val Town.
HTTP
# Elysia example
This is how you can use [Elysia](https://elysiajs.com) with Val Town.
export const elysia = async (req) => {
const items = [];
const { Elysia } = await import("https://esm.sh/elysia@0.7.15");
const app = new Elysia()
.get("/", () => items).post("/", () => items.push(Math.random()));
return app.fetch(req);
pomdtr avatar
apricotPartridge
@pomdtr
// use my private proxy
HTTP
import { setEnv } from "https://esm.town/v/pomdtr/setEnv";
// use my private proxy
setEnv("VALTOWN_API_URL", "https://pomdtr-tursoproxy.web.val.run");
// need to be dynamic
const { handler } = await import("https://esm.town/v/nbbaier/sqliteExplorerApp");
export default handler;
nbbaier avatar
cssReset
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
export const reset = `
Josh's Custom CSS Reset
https://www.joshwcomeau.com/css/custom-css-reset/
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
body {
line-height: 1.5;
-webkit-font-smoothing: antialiased;
img, picture, video, canvas, svg {
frankysnow avatar
xstateEx
@frankysnow
// Forked from @stevekrouse.xstateEx
Script
let { xstateStateEx } = await import("https://esm.town/v/frankysnow/xstateStateEx");
export const xstateEx = async (event: string) => {
const { createMachine } = await import("npm:xstate");
const toggleMachine = createMachine({
id: "toggle",
initial: "inactive",
states: {
inactive: { on: { TOGGLE: "active" } },
active: { on: { TOGGLE: "inactive" } },
let state = xstateStateEx || toggleMachine.initialState;
stevekrouse avatar
handleFormExample
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { email } from "https://esm.town/v/std/email?v=9";
export async function handleFormExample(req, res) {
await email({
text: JSON.stringify(req.query, null, 2),
subject: "New form submission",
myTestForm.push(req.query);
return res.send(`<h1>Hi ${req.query.first} ${req.query.last}!</h1>`);
neverstew avatar
saveFormData
@neverstew
An interactive, runnable TypeScript val by neverstew
HTTP
let { submittedEmailAddresses } = await import("https://esm.town/v/neverstew/submittedEmailAddresses");
export const saveFormData = async (req: Request) => {
// Create somewhere to store data if it doesn't already exist
if (submittedEmailAddresses === undefined) {
submittedEmailAddresses = [];
// Pick out the form data
const formData = await req.formData();
const emailAddress = formData.get("email");
if (submittedEmailAddresses.includes(emailAddress)) {
return new Response("you're already signed up!");
maxm avatar
streamingResponseExample
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
export default async function(req: Request): Promise<Response> {
let timer: number | undefined = undefined;
const body = new ReadableStream({
start(controller) {
timer = setInterval(() => {
const message = `It is ${new Date().toISOString()} ${getRandomEmoji()}\n`;
controller.enqueue(new TextEncoder().encode(message));
}, 200);
cancel() {
if (timer !== undefined) {
flymaster avatar
BugTracker
@flymaster
A simple bug tracker.
HTTP
A simple bug tracker.
export default async function(req: Request): Promise<Response> {
const app = new Hono();
app.use(
basicAuth({
username: Deno.env.get("USERNAME"),
password: Deno.env.get("PASSWORD"),
app.get("/", (c) => c.html(bugListTable("open")));
app.get("/all", (c) => c.html(bugListTable("all")));
app.get("/new", (c) => c.html(createBugForm(c.req)));