Back to APIs list

Github API examples & templates

Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
stevekrouse avatar
stevekrouse
button
HTTP
Forked from easrng/button
2
granin avatar
granin
sqliteExplorerApp
HTTP
Forked from nbbaier/sqliteExplorerApp
0
yieldray avatar
yieldray
minhtml
HTTP
An interactive, runnable TypeScript val by yieldray
0
mmorihara avatar
mmorihara
bloodyOliveMollusk
Script
WIP SQLite graph database based on https://github.com/dpapathanasiou/simple-graph
0
maxm avatar
maxm
tinygoHttpExample
HTTP
A Go http handler running in Val Town: The Go source is here . Mandelbrot rendering code taken from here . I used maxm/compileAndUploadTinygoWasm to compile the code and create the val. $ git clone git@github.com:maxmcd/go-town.git $ cd go-town/val-town-tinygo-http-example $ deno run --allow-net --allow-run --allow-read "https://esm.town/v/maxm/compileAndUploadTinygoWasm?v=58" Running tinygo build -o main.wasm -target=wasi . Compliation complete Running wasm-strip main.wasm Copy the following into a val town HTTP val: import { wasmHandler } from "https://esm.town/v/maxm/tinygoHttp"; const resp = await fetch("https://maxm-wasmblobhost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm"); const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer())); export default async function(req: Request): Promise<Response> { return handler(req); }
2
maxm avatar
maxm
compileAndUploadTinygoWasm
Script
Compile and Upload Tinygo WASM to Val Town Using Deno Make a Go program like so: package main import ( "fmt" "net/http" gotown "github.com/maxmcd/go-town" ) func main() { gotown.ListenAndServe(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello World") })) } Make sure you have tinygo (and optionally wasm-strip) installed. Then run this command with Deno to invoke this script: deno run --allow-net --allow-run --allow-read \ "https://esm.town/v/maxm/compileAndUploadTinygoWasm?v=58" That will print out the following: Running tinygo build -o main.wasm -target=wasi . Compliation complete Running wasm-strip main.wasm Copy the following into a val town HTTP val: import { wasmHandler } from "https://esm.town/v/maxm/tinygoHttp"; const resp = await fetch("https://maxm-wasmBlobHost.web.val.run/jpxqvyy5tphiwehzklmioklpkpz4gpzs.wasm"); const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer())); export default async function(req: Request): Promise<Response> { return handler(req); } Copy that into a Val and you have a working Go http handler! View that example here: https://www.val.town/v/maxm/crimsonMacaw
1
yieldray avatar
yieldray
minifyHTML
Script
Usage: import { minifyHTML } from "https://esm.town/v/yieldray/minifyHTML"; const minified = await minifyHTML("<html>...</html>", { ...options }); As an API: import { runVal } from "https://esm.town/v/std/runVal"; const minified = awaitrunVal("yieldray.minifyHTML", "<html>...</html>", { ...options });
1
jeffreyyoung avatar
jeffreyyoung
poe_bot
Script
// copied from https://github.com/poe-platform/fastapi_poe/blob/72e0ffdd00553d24ef23755138ca9b8d5f08b201/src/fastapi_poe/types.py
0
stevekrouse avatar
stevekrouse
dateMeDocs
Script
An interactive, runnable TypeScript val by stevekrouse
0
pomdtr avatar
pomdtr
tree_example
HTTP
View Example View Extension Repository #example
0
vladimyr avatar
vladimyr
jwkToDidKey_tests
Script
// @see: https://w3c-ccg.github.io/did-method-key/#example-5
0
dupontgu avatar
dupontgu
slamBotPost
Cron
// Replace with your actual access token and Mastodon instance URL
0
pomdtr avatar
pomdtr
lastlogin
Script
Lastlogin Authentication for val.town Looking for an hono integration ? See @pomdtr/lastloginHono Support login in trough: Email Link QR Code Google Oauth Github Oauth Gitlab Oauth Facebook Oauth Demo You can try a demo at https://pomdtr-lastloginhonoexample.web.val.run (see @pomdtr/lastLoginHonoExample for code) Usage Wrap your http handlers in a lastlogin middleware (sessions will be persisted in the lastlogin_session table on your sqlite account). If you want to be the only one able to access your val, you can use @pomdtr/verifyUserEmail. import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { // check that the user email match your val town email verifyEmail: verifyUserEmail }); If you want to customize how is allowed to signup, you can set the verifyEmail option: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { verifyEmail: (email) => { email == "steve@valtown" } }); You can allow anyone to signup by returning a boolean from the verifyEmail function: import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; export default lastlogin((req) => { return new Response(`You are logged in as ${req.headers.get("X-LastLogin-Email")}`); }, { verifyEmail: (_email) => true }); Public Routes import { lastlogin } from "https://esm.town/v/pomdtr/lastlogin"; import { verifyUserEmail } from "https://esm.town/v/pomdtr/verifyUserEmail"; export default lastlogin(() => { return new Response("Hi!"); }, { verifyEmail: verifyUserEmail, public_routes: ["/", "/public/*"], }); See the URLPattern API for reference. Logout Just redirect the user to /auth/logout
10
maxm avatar
maxm
emojiInstantSearch
HTTP
Forked from maxm/simpleWikipediaInstantSearch
2
alexwein avatar
alexwein
fabwbogglelike
HTTP
Forked from fil/earthquakes
0
maxm avatar
maxm
passkeys_demo
HTTP
Forked from stevekrouse/passkeys_demo
0