[Weekly Update] RainCrow, EVS, CCAM, SVGs
RainCrow has seen an uptick in use lately, with several days in a row exceeding the 1000 free OpenWeather API requests. This helped me focus on improving the error handling, making sure to show users an appropriate error when OpenWeather runs out of requests for the day.
With fresh eyes, I was able to fix an old problem and cut down on OpenWeather API calls by over 33%! When RainCrow was fully client-side, I was unable to use node.js libraries like node-geo-tz that can return timezone names from GPS coordinates because that would involve sending the entirety of worldwide timezone data to the browser for every use. Since OpenWeather returns timezone offset data with their requests, I initially settled on making an additional preliminary OpenWeather request to get the timezone data before making the actual weather requests.
However, since moving to Sveltekit and therefore having servers (or more specifically, serverless functions) at my disposal,
node-geo-tz was now on the table. After a bit more head-scratching on how to convert a named timezone to a UTC offset (they are not equivalent!) I was able to eliminate the extra OpenWeather API timezone call. This will cut down requests by 33-50%, which rocks.
I used Day.js to append the timezone name returned from node-geo-tz to all datetimes, which then uses the native Internationalization API to calculate the offset and give you the proper unix time.
I've learned it over and over: datetimes are surprisingly tricky to work with! I initially didn't include the optional
true parameter to the
tz method, which when left off doesn't just edit the timezone but converts the time as well. As I was testing data locally, there was no problem because the calculations were happening on a computer in Phoenix with data from Phoenix so the conversion had no effect. Once in production though, times got wonky. Thankfully I caught and fixed that quickly.
I got busy on a new email feature for the EVS application. It basically allows admins to send custom emails to select groups with defined roles within the application. It uses Resend to send the emails, React Email for email formatting, and as Zod and conform for validation and error handling. Pull Requests: 61, 62, 63.
There are some more error cases to account for but a good start on a 'Must have' feature before we can put the application into production.
I also got started with a website rebuild I'm consulting on. I'm working off an awesome design from Ioan Butiu and thinking carefully about how best to structure the data, content, and components for maximum code legibility and ease of editing down the road. CCAM website maintainers will be tech-saavy so using markdown and other simple data structures for editing content is preferable but bringing in a CMS like Sanity might be on the table as well.
I came across a fun Christmas-y SVG tutorial (which for some reason is not called Advent of SVG). I've used SVGs plenty but never considered manually writing the code or understanding much of its contents beyond a few choice attributes. Learning fundamentals like this makes me unreasonably happy.
And now, I leave you with a cheery SVG tree: