Last week I put together a super light weight app I’ve been meaning to make for a while–a personal URL shortener. In every step of creating the app I used a method my friend, Nick Ang, calls light touch.
A light touch as Nick describes it:
This light touch might just be the only way to guarantee that we will get to partake in as many of our curious pursuits as possible until our cold end.
The truth is I have been trying to build this app for quite some time. I tried building it in Rails, Node and serverless with AWS Lambda. And along the way I kept getting stumped. Usually because I was trying to learn something new, do something clever or was coming up with a completely, over complicated solution.
What finally forced me to get this URL shortener up and running is this mail chain kids have been participating in ever since the pandemic hit. The idea is to send stickers around and receive stickers from friends of friends. The part which didn’t sit right with me is you’re supposed to make photo copies of one of two copies of a form you receive to then send off to six other people.
Who has a scanner in their house these days?! Asking someone to make a copy felt like too much of a burden to ask. So I figured a short URL would be a sleeker solution. My wife on the other hand did not appreciate my idea. She gave me a week to figure out my URL shortener or she’d send out the original instructions which instructs you to make photo copies.
You might be saying at this time, Michael nothing about this feels like a light touch. And you’re right! But I enjoy programming and it was a good learning experience. Not to mention I now have my own personal URL shortener.
The application has two routes. One for the short URLs and the other to handle the base URL.
For the database—this is where things get light—I chose SQLite. I didn’t want to waste time setting up a database. I needed something simple and since I was the only using the app, I didn’t need a lot. So I chose SQLite. The benefits of using SQLite is that it’s self-contained to a single file, for which I can easily transport between my computer and my server by means of SFTP.
For the server this is where this got really interesting. At first I was trying to get things set up with AWS Elasticbeanstalk. But the resources that would be consumed and the level of overhead for the infrastructure felt too costly and too complicated. I just needed something light weight.
I had used AWS Lightsail before at work. It was quite simple to use. So I decided to go with Lightsail for my shortener. I chose the Node instance from Bitnami and with a few button clicks my server was provisioned. The nice thing about the preconfigured instance is that it has a version of Node already, has Apache running and everything set up fairly easily so that I can get up and running.
Once my server was up I was trying to decide which was the best way to get my application up and running on the server. At first I thought using Git and Github was the way to go. But the more I thought about it it felt too heavy with having to set up ssh keys and what not. Back in the day when I was an early developer dabbling in PHP I remembered how magical it felt to simply connect to a server via SFTP, drag some files and then immediately see the changes. I wondered if I could that with Node.
So I created a folder on the server, transferred my project minus the
node_modules folder via SFTP, ran
npm install and lo and behold the app was running. Smiles all around because it felt just as magical as when I first did it in Wordpress land so many years ago.
While there is much room to improve upon the setup, the point wasn’t to do things “properly” it was to keep having forward momentum, to keep having fun and to meet my wife’s deadline of having this thing up in a week. And I succeeded by using a light touch method to create a URL shortener—mslee.link.