pomdtr avatar
pomdtr
valtownByExample
HTTP
Val town by example Usage Simple Example To add an example, just create a val. The val should start with a JSDoc style multi line comment that describes the example: /** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. */ // this comment will be displayed on the left export const server = () => new Response("Hello world!") The title is required. Then, you can write the code. Code can be prefixed with a comment that describes the code. The comment will be rendered next to the code in the example page. Make sure your val is public, then go to https://pomdtr-val_town_by_example.web.val.run/v/<your-username>/<your-val> Using multiple vals You can add another val to your example by adding an @include directive /** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. * @include pomdtr/secondary_val */ See @pomdtr/react_example Adding external resources to your example You can attach an external link to your val by using the @resource directive. External resources are specified using a markdown link. /** * @title HTTP server: Hello World * @description An example of a HTTP server that serves a "Hello World" message. * @resource [Val Town Docs](https://docs.val.town) **/ Adding examples to the homepage Just add your val in @pomdtr/val_town_by_example_toc
3
tmcw avatar
tmcw
whenfilmed
HTTP
A game where you guess when a movie was released. Man, those Disney movies are ancient !
2
demon avatar
demon
valleBlogV0
HTTP
Forked from janpaul123/valleBlogV0
0
charmaine avatar
charmaine
forwarder
Email
Forked from stevekrouse/forwarder
0
kortina avatar
kortina
subaudio
HTTP
sub.audio – generate subtitles and chapters for any audio URL. Speech-to-text and chapter summaries powered by Substrate đŸĒŠ To fork, sign up for Substrate to get your own API key and $50 free credits
0
stevekrouse avatar
stevekrouse
gitReleaseNotes
HTTP
Forked from kylem/gitReleaseNotes
0
pomdtr avatar
pomdtr
indieauth_server
HTTP
@jsxImportSource npm:hono/jsx
0
stevekrouse avatar
stevekrouse
hardwarebingo
HTTP
Hardware Startup 2024 Bingo Made with Claude Artifacts
1
gitgrooves avatar
gitgrooves
VALLE
HTTP
Forked from janpaul123/VALLE
0
vladimyr avatar
vladimyr
keyvhq_blob_example2
Script
Forked from vladimyr/keyvhq_example2
0
nbbaier avatar
nbbaier
lowdbTest
HTTP
Forked from pomdtr/lowdb_example
0
kate avatar
kate
VALLE
HTTP
Forked from janpaul123/VALLE
0
vladimyr avatar
vladimyr
bookmarklets
HTTP
Forked from pomdtr/bookmarklets
0
stevekrouse avatar
stevekrouse
grievingYellowAsp
HTTP
Forked from stevekrouse/perf
0
paras avatar
paras
k
Email
Forked from stevekrouse/forwarder
0
postpostscript avatar
postpostscript
blogSqliteUniversePart2
HTTP
sqliteUniverse: Make SQLite Queries Against Multiple Endpoints in Deno (Val Town) (Part 2) If you haven't already, check out Part 1 for an overview of this system! Examples Example: find my vals that are related to my public tables import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder"; import { sqliteUniverse } from "https://esm.town/v/postpostscript/sqliteUniverse"; console.log(await Statement` SELECT v.name AS val, t.name AS "table" FROM "https://postpostscript-sqlitevals.web.val.run/vals" v INNER JOIN "https://postpostscript-sqlitepublic.web.val.run/sqlite_schema" t ON t.name LIKE ('https://postpostscript-sqlitepublic.web.val.run/' || v.name || '%') AND t.type = 'table' WHERE v.author_username = 'postpostscript' `.execute({ sqlite: sqliteUniverse, })) Since table names matching /^@/ will let you pass val names in the place of their HTTP endpoints, we can write the query as: SELECT v.name AS val, t.name AS "table" FROM "@postpostscript/sqliteVals/vals" v INNER JOIN "@postpostscript/sqlitePublic/sqlite_schema" t ON t.name LIKE ('@postpostscript/sqlitePublic/' || v.name || '%') AND t.type = 'table' WHERE v.author_username = 'postpostscript' The result for the latter: [ { val: "authId", table: "@postpostscript/sqlitePublic/authIdExampleComments_comment" }, { val: "authIdExampleComments", table: "@postpostscript/sqlitePublic/authIdExampleComments_comment" } ] Example: query against a backup import { sqliteFromBlob } from "https://esm.town/v/postpostscript/sqliteBackup"; import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder"; import { defaultPatterns, patterns, sqliteUniverseWithOptions } from "https://esm.town/v/postpostscript/sqliteUniverse"; const sqlite = sqliteUniverseWithOptions({ interfaces: { patterns: [ ...defaultPatterns, patterns.blob, ], }, }); console.log(await Statement` SELECT * FROM "blob://backup:sqlite:1709960402936/someTable" `.execute({ sqlite })); Example: query from @std/sqlite and public data simultaneously import { sqliteFromBlob } from "https://esm.town/v/postpostscript/sqliteBackup"; import { Statement } from "https://esm.town/v/postpostscript/sqliteBuilder"; import { defaultPatterns, sqliteUniverseWithOptions } from "https://esm.town/v/postpostscript/sqliteUniverse"; import { sqlite as sqlitePrivate } from "https://esm.town/v/std/sqlite?v=4"; const sqlite = sqliteUniverseWithOptions({ interfaces: { patterns: defaultPatterns, fallback({ endpoint, tables }) { return sqlitePrivate }, }, }); console.log(await Statement` SELECT t.*, p.* FROM privateTable t JOIN "@example/sqlitePublic/publicTable" p `.execute({ sqlite })); You could also do it like this to make it more explicit: const sqlite = sqliteUniverseWithOptions({ interfaces: { exact: { "@std/sqlite": sqlitePrivate, }, patterns: defaultPatterns, }, }); console.log(await Statement` SELECT t.*, p.* FROM "@std/sqlite/privateTable" t JOIN "@example/sqlitePublic/publicTable" p `.execute({ sqlite })); Next Steps I'd like to make patterns to allow queries against JSON and Val/ESM exports e.g. SELECT * FROM "json://example.com/example.json" or SELECT * FROM "export://@postpostscript/someVal/someExport" but those will have to come later! Another necessary feature for querying against larger databases will be to use the WHERE or JOIN conditions when dumping from them, but this will be more complicated P.S. This has been a super fun project to work on and I hope you find it interesting or inspiring too! Let me know if you find any errors in this post or if you'd like me to expand more on a specific feature, and let me know if you make anything cool with this and I'll make a note of it! P.P.S (😏) this interface is not 100% stable yet, so I would recommend pinning to specific versions if it not breaking is important to you P.P.P.S. Want to serve your own public SQLite endpoints? This is currently the simplest example I have of how to do that: @postpostscript/sqlitePublic
1
Updated: January 8, 2025