Search

Results include substring matches and semantically similar vals. Learn more
ming avatar
postWebhook
@ming
An interactive, runnable TypeScript val by ming
Script
export let postWebhook = (req, res) => {};
begoon avatar
ghdb
@begoon
This val implements a simple key/value database with GitHub, in a CRUD way. The key is a file path within a repository. The value is the file content. The val needs a GitHub token to access the GitHub API, the account name and the repository name. Also, the val needs GHDB_API_KEY variable. This value defines the exptected value of the GHDB_API_KEY header to allow access to the endpoints. Endpoints: GET /data/path/to/file.ext - read file GET /raw/path/to/file.ext - read file from GitHub CDN (10 times faster) DELETE /data/path/to/file.ext - delete file POST /data/path/to/file.ext - create file PUT /data/path/to/file.ext - update/commit file
HTTP
This val implements a simple key/value database with GitHub, in a CRUD way.
The key is a file path within a repository. The value is the file content.
The val needs a GitHub token to access the GitHub API, the account name
and the repository name.
Also, the val needs GHDB_API_KEY variable. This value defines the exptected
value of the GHDB_API_KEY header to allow access to the endpoints.
consola.options.formatOptions.columns = 0;
consola.options.formatOptions.compact = false;
export type Data = {
content: string | Uint8Array;
u avatar
schema
@u
An interactive, runnable TypeScript val by u
Script
export function schema(req, res) {
patmood avatar
home
@patmood
An interactive, runnable TypeScript val by patmood
Script
export let home = (req: express.Request, res: express.Response) => {
res.send("<h1>hi</h1>");
stevekrouse avatar
lastlogin_safe
@stevekrouse
Cross-platform safe Last Login Middleware This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lastlogin was written, but to make it safe to import on the frontend, because it only imports the backend stuff dynamically per request.
Script
# Cross-platform safe Last Login Middleware
This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lastlogin was written, but to make it safe t
export const lastlogin = (handler) => (async (req) => {
const { lastlogin } = await import("https://esm.town/v/stevekrouse/lastlogin");
return lastlogin(handler)(req);
stevekrouse avatar
edit_redirect_example
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP (deprecated)
import { Hono } from "npm:hono@3";
const app = new Hono();
app.get("/", (c) => c.text("Hello world!"));
app.get("/edit", (c) => editRedirect());
export default app.fetch;
wilt avatar
pug
@wilt
Pug HTML Template Renderer This function is equivalent to pug.render - it takes a Pug template string and renders it to an HTML string. import(npm:pug) doesn't work in Val.Town due to Pug's usage of new Function , which is forbidden for security reasons, so this function uses Val.Town's eval API instead. Example const myEndpoint = async (req: express.Request, res: express.Response) => { const html = await @wilt.pug("p Hello #{name}!", {name: "Pug"}); res.status(200); res.send(html); }
Script
# Pug HTML Template Renderer
This function is equivalent to [`pug.render`](https://pugjs.org/api/reference.html#pugrendersource-options-callback) - it tak
## Example
```javascript
const myEndpoint = async (req: express.Request, res: express.Response) => {
const html = await @wilt.pug("p Hello #{name}!", {name: "Pug"});
export async function pug(
templateStr: string,
args = {},
// Not sure why anyone would use this callback, but it's included for compatibility with pug.render
janpaul123 avatar
valle_tmp_50644780717275968385591250334155
@janpaul123
// The simplest approach to fulfill this request is to create an HTTP handler that responds to all requests with "Hello world" using the built-in Response class in TypeScript.
HTTP (deprecated)
// The simplest approach to fulfill this request is to create an HTTP handler that responds to all requests with "Hello world
* HTTP Val: Hello World Example
* This script will respond with "Hello world" to any incoming HTTP request.
export default async function(req: Request): Promise<Response> {
return new Response("Hello world", {
headers: { "Content-Type": "text/plain" },
vladimyr avatar
jsr
@vladimyr
Try on Val Town This service enables quick generation of new val with specified jsr package. Package authors can provide custom examples by setting either: valtownExample property of jsr.json / deno.json to contain example js/ts code valtownExampleFilename property of jsr.json / deno.json to point to the file with example js/ts code If no example is found val will be created with the default snippet, using @luca/flag as an example : import * as flag from "jsr:@luca/flag"; Go ahead ā†—ļø try it (on Val Town) ! šŸŽ‰ Additionally, the service supports ?code=<base64code> query param that allows overriding extracted/generated example code. For example one might want to override @luca/flag 's snippet with: import { printProgress } from "jsr:@luca/flag@1"; printProgress(); In order to do so first you need to convert it to base64: $ printf 'import { printProgress } from "jsr:@luca/flag@1";\n\nprintProgress();' | base64 -w0 # ==> aW1wb3J0IHsgcHJpbnRQcm9ncmVzcyB9IGZyb20gImpzcjpAbHVjYS9mbGFnQDEiOwoKcHJpbnRQcm9ncmVzcygpOw== Then you simply construct the URL by setting the returned value to code query param: ā†—ļø https://vladimyr-jsr.web.val.run?code=aW1wb3J0IHsgcH... Usage https://vladimyr-jsr.web.val.run/<scope>/<name>[@<version>] https://vladimyr-jsr.web.val.run?code=<base64code> Example https://vladimyr-jsr.web.val.run/@luca/flag https://vladimyr-jsr.web.val.run/@std/assert@0.220.1 https://vladimyr-jsr.web.val.run/@mark/html@latest
HTTP (deprecated)
# Try on Val Town
[![](https://vladimyr-licensebadge.web.val.run/v/vladimyr/jsr)](https://spdx.org/licenses/0BSD.html)
This service enables quick generation of new val with specified [jsr](https://jsr.io) package.
Package authors can provide custom examples by setting either:
- `valtownExample` property of [`jsr.json`](https://jsr.io/docs/package-configuration)/[`deno.json`](https://docs.deno.com/ru
- `valtownExampleFilename` property of [`jsr.json`](https://jsr.io/docs/package-configuration)/[`deno.json`](https://docs.den
// SPDX-License-Identifier: 0BSD
export default async function(req: Request, options?: {
transformReadme: HtmlProcessor;
}): Promise<Response> {
dharmatech avatar
easyAQIExample
@dharmatech
An interactive, runnable TypeScript val by dharmatech
Script
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=3";
export const easyAQIExample = easyAQI({
location: "brooklyn navy yard",
webup avatar
pipeSampleLLMBind
@webup
An interactive, runnable TypeScript val by webup
Script
export const pipeSampleLLMBind = (async () => {
const { PromptTemplate } = await import("npm:langchain/prompts");
const prompt = PromptTemplate.fromTemplate(`Tell me a joke about {subject}`);
const mb = await getModelBuilder({
type: "chat",
provider: "openai",
const model = await mb();
const tb = await getLangSmithBuilder();
const tracer = await tb();
const functionSchema = [
maxm avatar
retroVisitCounter
@maxm
Retro Visit Counter You are visitor number: How special! Want a retro visitor counter for your myspace page or geocities website? Fork this val and add the image link to your website: <img src="https://maxm-retrovisitcounter.web.val.run/counter.png"> <!-- Make sure you swap this subdomain out with the subdomain of your forked val --> <img src="https://[CHANGE ME!].web.val.run/counter.png">
HTTP (deprecated)
# Retro Visit Counter
You are visitor number: ![](https://maxm-retrovisitcounter.web.val.run/counter.png)
How special!
Want a retro visitor counter for your myspace page or geocities website? Fork this val and add the image link to your website
<img src="https://maxm-retrovisitcounter.web.val.run/counter.png">
<!-- Make sure you swap this subdomain out with the subdomain of your forked val -->
await sqlite.execute(`create table if not exists counter(
name text,
counter integer
async function getCurrentCount(): Promise<number> {
simonharrisco avatar
ping2
@simonharrisco
An interactive, runnable TypeScript val by simonharrisco
Cron
import { fetchHTML } from "https://esm.town/v/stevekrouse/fetchHTML?v=9";
export function ping2() {
fetchHTML("https://simonharrisco-site.vercel.app/");
iamseeley avatar
animateElement
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
export function animateElement(element, delay) {
return new Promise(resolve => {
setTimeout(() => {
element.classList.add('in-view');
resolve();
}, delay);
export async function animateElementsSimultaneously(elements, initialDelay) {
const promises = elements.map(element => animateElement(element, initialDelay));
await Promise.all(promises);
qiangua avatar
similarSites
@qiangua
Find similar pages on HN and return a streaming markdown summary. Powered by Exa and Substrate . šŸŖ© To fork, sign up for Substrate to get your own API key and $50 free credits.
HTTP (deprecated)
Find similar pages on HN and return a streaming markdown summary.
Powered by [Exa](https://exa.ai/) and [Substrate](https://substrate.run).
šŸŖ© To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits.
const exa = new Exa(Deno.env.get("EXA_API_KEY"));
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
export default async function handler(req: Request): Promise<Response> {
const url = new URL(req.url).searchParams.get("url") || "https://thesephist.com/posts/synth/";
const searchResults = await exa.findSimilarAndContents(url, {
text: { maxCharacters: 1000 },
category: "personal site",