Repository navigation
Serve the shortlink service on Deno Deploy v2 - #10
Open
EthanThatOneKid wants to merge 3 commits into
Open
EthanThatOneKid wants to merge 3 commits into
EthanThatOneKid wants to merge 3 commits into
Conversation
added 3 commits
September 23, 2026 05:39
Export a default fetch handler so the new Deno Deploy runtime can serve the router, and make the Deno KV layer optional: the service now boots with the committed links.json ruleset, merges KV entries when a database is bound, and returns 503 from the write endpoints when it is not. Commit the FartLabs shortlinks (chat, twitter, instagram, in) so the ruleset is versioned.
The CLI called Deno.openKv() and Deno.serve() at module scope, which made the service fail to boot on Deno Deploy v2: the platform needs a default export and no database was bound. Now: - export a fetch handler so Deno Deploy can serve the app, keeping the import.meta.main path for local deno run - treat Deno KV as an optional overlay on links.json, so the service boots and resolves links even when no KV database is assigned (writes answer 503 instead of crashing the process) - answer 404 for paths that do not resolve to a shortlink instead of redirecting a request to itself Also commits the FartLabs shortlinks (chat, in, instagram, twitter) to links.json so the deployed service resolves them without KV.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the
go.fart.toolsshortlink service runnable on the current Deno Deploy platform, which is what the hostname needs before it can come back.Three changes:
cli/main.tsxexported nothing, so the new runtime had no handler to serve (the app's only build failed). It now exportsdefault { fetch }through a lazily-initialized router, and keeps the localdeno runpath behindimport.meta.main.Deno.openKv()used to run unconditionally at startup, so the process died without a bound database. The service now reads the committedlinks.jsonruleset as its base, merges KV entries when a database is available, and returns503fromPOST/DELETE /apiwhen it is not. Reads and redirects always work.links.jsongains the four shortlinks the live site and blog use —chat,twitter,instagram,in— so the service serves them without any database.A second commit applies
deno fmttoREADME.mdanddemo/browser.html; they are unformatted under the current Deno, which makes the Check workflow's format gate fail on any new push.Verified locally
deno fmt --check,deno lint,deno test— clean, 15 tests pass.GET /apireturned the merged ruleset, and/chat,/twitter,/instagram,/inall returned302to the expected destinations (the Discord invite,https://x.com/fartlabs_org,https://instagram.com/fartlabs,https://linkedin.com/company/fartlabs).links.json,POST /apireturned503with an explanatory message instead of crashing.Notes for review
go-fart-tools; this PR is the repo-side counterpart so the fix lives in git.fart.tools's KV instance limit is 1 on the current plan and it is already taken byworlds-api, so production runs the read-only ruleset until a database can be bound — the write endpoints come back the moment one is.