a url shortener built using hono on the cloudflare developer platform (workers & kv).
using this button, you can deploy rinko to cloudflare workers, but it won't have a defined API_SECRET; learn more just below.
to manage your links, go to /_ or click on "admin panel".
in local development, the api is protected by the token specified in
.dev.vars.when deploying, you need to use the cloudflare dashboard or
wranglerto add anAPI_SECRETenvironment variable to your worker. worker secrets / cloudflare docs >
this endpoint accepts both
application/json&application/x-www-form-urlencodedpayloads.
slug: the short link itself; if you put123as slug, you'd go tohxxps://[rinko]/123. if empty or not given, it creates a random 4-character slug.url: the destination link.overwrite: true/false: if true, overwrites the link if there was one. if nourlgiven, it deletes the specified short link.
$ curl hxxps://[rinko]/_/set -d "url=https://google.com" -H "Authorization: Bearer {api token}"
{"slug":"oNcK","url":"https://google.com","link":"/oNcK"}$ curl hxxps://[rinko]/_/set -d "url=https://google.com&slug=google" -H "Authorization: Bearer {api token}"
{"slug":"google","url":"https://google.com","link":"/google"}
$ curl hxxps://[rinko]/_/set -d "url=https://google.co.jp&slug=google" -H "Authorization: Bearer {api token}"
{"slug":"google","url":"https://google.com","link":"/google","message":"Did not update google because it already was pointing to https://google.com and overwrite was set to false."}
$ curl hxxps://[rinko]/_/set -d "url=https://google.co.jp&slug=google&overwrite=true" -H "Authorization: Bearer {api token}"
{"slug":"google","url":"https://google.co.jp","link":"/google"}$ curl hxxps://[rinko]/_/set -d "slug=google&overwrite=true" -H "Authorization: Bearer {api token}"
{"slug":"google","message":"Deleted link google"}- returns the list of all short links with their destinations.
[
{
"slug": "google",
"url": "https://google.co.jp",
"link": "/google"
},
{
"slug": "github",
"url": "https://github.com/apix0n",
"link": "/github"
},
{
"slug": "yt/video",
"url": "https://www.youtube.com/watch?v=shs0rAiwsGQ",
"link": "/yt/video"
}
]- use
_as a slug that matches the root page, - use
_404as a slug to replace where the 404 redirects to
_/prefixes (e.g., _/something),.,..,../,./relative urls links,favicon.ico
rinko can behave as a "search engine" for browsers using the format hxxps://[rinko]/_/search?q=%s where %s is the url encoded query, and where a space becomes a trailing slash; which redirects to hxxps://[rinko]/query.
to register rinko as a search engine, go to hxxps://[rinko]/ and it should install to your browser automatically.
if it doesn't work, copy the given link and add it as a custom search engine.
hxxps://[rinko]/_/search?q=googleredirects tohxxps://[rinko]/googlewhich itself redirects tohttps://google.co.jphxxps://[rinko]/_/search?q=githubredirects tohxxps://[rinko]/githubwhich itself redirects tohttps://github.com/apix0nhxxps://[rinko]/_/search?q=yt%20video(hxxps://[rinko]/_/search?q=yt video) redirects tohxxps://[rinko]/yt/videowhich itself redirects tohttps://www.youtube.com/watch?v=shs0rAiwsGQ
npm install- create a new
kvservice to keep the links:
npx wrangler kv namespace create LINKS- replace the
kv_namespacessection of thewrangler.jsoncfile - copy the .dev.vars.example to
.dev.vars(for local development) and change the values - regenerate types:
npm run cf-typegennpm run devnpm run deploy