Serverless v0.1
Published: 1/28/2022
I didnāt actually know what serverless was š¤
Iāve been keeping a list of things I want to learn next. Iāve had both āWes Bosās Node courseā and āserverlessā on that list for some time. This week, I decided on the Node.js course.
Pretty quickly it started to look very dated š“. For example, it uses Pug for HTML templating, and serves everything from the backend using a MVC model. Iāve not seen this in use since I started using JS several years ago, but it made me think back to my days learning Ruby on Rails. Iāll be honest, I didnāt want to learn Pug or even muck around in it.
It did make me realize, in sort of brain expanding way š¤Æ, the niche that the JS frameworks Iāve been using occupy. Theyāve replaced the sort of HTML templating on the backend that was used in this video. For a time, people moved as far away from server-side rendering as they could, writing Single Page Apps that Viewing and Controlling. They just needed data to feed them, if that, and so you have backend-CMS tools and tools like Supabase that provide a data backend.
I realized that a tool like Keystone, which I used for a project, is using an older non-Software-as-a-service model. Itās built on Express, which is what Wes was using in this Node course for his backend. I found Keystone to be a bit of a pain. When your starting place if SaS, itās hard to believe that you need to rent a server, run your backend and DB on it, and do all of the care-and-feeding. I mean, itās probably closer to my skill set, as a Linux junior-SA, than actual web-dev, but still, the idea of keeping up with a bunch of servers for all the little projectsā¦yuck. Any actually having to pay for them? Whereās the free tier?
So all of this kind of laid the groundwork for me to have my little eurika moment on serverless. Oh, so I use the SaS model, but for the backend stuff š¤Æ? For some reason I thought it was for little micro-processes. Maybe at one point it was? But what Cloudflare has going on makes me think you could really replace the old you-own/rent-the-server model. Iām into it!
Serverless Projects
So far Iāve done two projects:
- A Hello World that uses Cloudflare headers to display your location.
- A simple API that takes a query from a React app, searches Unsplash with the term, and returns a simplified version of Unsplash results to the app for display.
Both were tutorials found on the cloudflare website.
I marched right along yesterday following the tutorials. Of course, the fun starts when you step away for a day and come back. My new domain was absorbed into Cloudflare, so I wanted to set up custom domains for the projects. Thatās where I ran into a mish-mash of CORS and DNS issues (everyoneās favorite!) that had me scratching my head for hours, cursing, taking a walk, and coming back for serious troubleshooting.
I really want to like Cloudflare, but I think they have a little DX to work out. The build times, for starters, are significantly slower than Netlify/Vercel, as far as I can tell. Even setting up a simple HTML landing page via Cloudflare Pages had me tapping my foot with impatience. There are also lags with publishing workers that make troubleshooting harder. āAm I looking at the old instance of the worker or the new one?ā you might find yourself asking. Then you have a DNS tab, a workers tab, and a Pages tab, several worker files, and then your wrangler-cli terminals that you are bouncing between, and sometimes they are linked together and sometimes they arenāt š š¢.
Nonetheless, I suspect theyāll keep ironing things out as they go, and the promise, for me, outweighs the pain. Onward!