URL Shortener
Welcome to my first attempt at a Coding Challenge from John Crickett. In many ways, this entire website is an ode to Mr. Crickett, who takes the stance that the only way to build your muscles as a developer is to, well, actually build stuff. This "stuff" is a URL shortener (link to the Coding Challenge if you're interested), similar to Bit.ly or Tiny.url.
In this challege, my goal was to stretch my React muscles a bit while also learning about Cloud Firestore, a NoSQL database provided by Google. This project represents the first bit of data persistence on the Playground (the Simple Todo List just uses localstorage).
To use the URL shortener, simply add the URL you with to shorten and you'll get a new version of that URL (potenially longer than the original version as I'm using the URL of this site, but here we are). You can immediately copy that URL or come back to this page and find it again by hovering over each shortened URL to see the full URL as a tooltip. If you don't want anyone else to see the URL you saved, you can delete it at any point. Additionally, there's a click to copy button for each URL.
Some cool parts about this challenge:
- This is my first time using a NoSQL database; Firestore made this incredibly easy. Hats off to the Googs.
- I used Blake2b to generate the hashes for the URLs. Each hash is 6 characters long and made of numbers 0-9 and lowercase letters in the alphabet for a total of 35 possible characters. That gives me 2,176,782,336 possible combinations before running out of space. I'm not handling collisions right now; it's a straight write through to the Firestore collection; an area of future improvement if I so desire.
- The REST API supports POSTs, GETs, and DELETEs.