Go (URL Shortener)

Go is a tiny Node.js application I worked on and put together in about 4-5 hours.
I usually take a lot longer working on projects so under 5 hours was very very quick for me.
I decided to use go.mhmd.us because I already am using mhmd.us to host my droplr links and content.

Usage

I'd like to welcome you to try out this URL shortener with the caveat that it is only for demo purposes right now.
You can start using it by sending a curl request like below:

curl -X POST \
    http://go.mhmd.us/shorten \
    -H 'Content-Type: application/json' \
    -d '{
    "url": "https://your-long-url.com",
}'
        
You can also pass in an option "custom" key/value pair to get a custom path.
If all goes well, you will get a OK 200 with the JSON response including the short and long links.

Details

I decided to try the simplest way to create a key/value pair system to save the data necessary to run a URL shortener.
So, I went with using two JSON files to save long and short URL pairs. I am using two JSON files, one where the short URL is the key and one where the long URL is the key.

short-links.json
{
    "about": "http://usmanity.com/projects/go"
}
        
The above shows this page's entry in the JSON file for short links.

The lookup speeds for each file are O(1). Since looking up any file in a JSON structure in JS will be the fastest if it's looked up using a key. See in this JSPerf example (link), this works well if the lookup is just simply the key in an object and we only want the value from that key.
The size of the file will continue to increase so I will add a way to check the average lookup time for links over a certain period of time.