trinket-blog/articles/Updated URL Shortener.md

25 lines
1.5 KiB
Markdown

Lately, I've been interested in improving my URL shortener hosted at [https://trkt.in](https://trkt.in). So I did!
I present.. **Chela!**
I named Chela off of the small claw on crabs because it's like the little claw compared to the big one. Ok, I admit the name is vague but I think it's cute.
I built Chela in Rust using Axum as a server framework. It runs off of a Postgres database. It's very simple by design and also very fast. Using `curl`, I get a response in around a millisecond typically.
In my previous iteration of this project, I rather lazily generated IDs by hashing the URLs and then taking the first four or so letters. It was ugly and at increasing risk of collision.
In this new iteration, I'm using [Sqids](https://sqids.org/) to generate IDs. It's better, faster (I think), and it looks prettier.
For example,
- [https://trkt.in/2614aab104d](https://trkt.in/2614aab104d)
- [https://trkt.in/WX](https://trkt.in/WX)
These both link to the same website (my previous blog post), but one of them is a whole lot easier to remember.
Also, this new version supports the `+` feature from bit.ly, where if you put a plus sign at the end of a URL it will show you what it links to. Try it!
I made the Docker image for Chela as small as I could without going off the deep end. The Chela binary is around 5Mb, and the full Docker image is just about 14Mb not including the Postgres dependency.
If you're interested, feel free to check it out here: [https://trkt.in/oz](https://trkt.in/oz).