I’m Back!

- by Colin on 19-8-2022
struggling-garden

A Struggling Garden

Hello! It’s been over a year since I publish an “official” post (excluding the mdx section of my site). I feel I have some reasonable excuses, not that there are any readers out there in WWW land. In September2021 I started working as a Music Instructor at TangHallSmartCIC (THS). It is thoroughly enriching opportunity and I’ve been able to play and perform as a Guitarist, Bassist, Drummer, Pianist and even some singing. Screaming In the case of Megadeth and Three Days Grace cover songs.

12 months of web dev!

Although my work at THS requires my immediate focus on day-to-day basis, I have made some progress on my web dev projects. When I first started thinking over the past 12 months and looked at the blog I was fairly disappointed, there hasn’t been many posts over the year. On digging a little deeper, my feelings took a positive turn. Here’s a brief overview of what I have been up to…

MDX notes

I have added an MDX section to my personal website. Using MDX is quicker and easier than the a CMS editor like the WP Gutenberg or WYSIWYG for writing, especially in note-like form. Code highlighting in Gutenberg blocks with headless WP isn’t particularly pretty.

React-Query / Tanstack

I’ve spent a reasonable amount of time experimenting with React-Query. I was particularly drawn to RQ as because it’s promised based, it is somewhat agnostic, technologically. It makes it possible to hook into various “Fetch/Request middleware”. As WordPress provides a standard REST API and the WPGraphQL plugin provides a GQL Schema, RQ would be able to support both without much hassle. Plus, it offers a very React friendly way of cacheing and managing data sent to the client.

Authenticating/Registering Users via CORS Cookies

There is a sign up form here allowing registered users to access secret content that is only available to subscribers. Not that there is anything interesting… Or is there? It’s more about the concept, this has been implemented with CORS cookies provided from native WordPress. It has been ported directly from Kellen Mace’s excellent video instruction and blog post on the Native WordPress CORS Security Cookies. Instead of using Apollo, I’ve used React-Query. There have been some creepy crawlies, but things from my side should be working… It is particularly satisfying to be able to query and CRUD live data from a static site.

Authenticating Users Via JWT

I’ve also experimented with using the JWT provided from WordPress. Both Cors and JWT methods can function effectively, but both work in a slightly different manner. If you want to find out more it is somewhere over in my MDX notes.

TypeScript

My first introduction to C# happened from attending local code dojos and Dotnet meet ups. Coming from self-taught JavaScript, C# is intimidating and frustrating for a variety of reasons. Not being able to use some dependencies that are incompatible with MacOS became a bit of a problem for me. However, I could see the huge advantage of a strongly-typed language provided, and this is what TypeScript manages, but for JS. I wondered whether strongly-typing JS was to misunderstand the advantages of a loosely-typed interpreted language, but I suspect this is due to my coding naivety. However, I don’t think it’s uncommon to come across TS projects online that aren’t written effectively, TS seems to be a hinderance rather than a benefit. EG overuse of the Any type

However, the popularity of TS made it difficult to ignore and I figured that it would be beneficial to learn TypeScript and become more proficient in strong-typed languages. Many of the features, such as auto-importing and code refactoring, pleasantly surprised me.

One HUGE advantage when using GatsbyJS, is that it is pretty much seamless to run JS and TS alongside each other. Allowing for a more granular decision making EG: complex logic to be type-checked or perhaps a more simple functionality TS is unnecessary overhead.

Testing and Test-Driven-Development

I’ve been trying to further my intuition when it comes to testing and embracing a TDD philosophy. As I am inexperienced with the subjects I have often broken the rules and not always followed a fail->pass. This has perhaps been due to making mistakes with regard to implementation particularly with regard to stubs/mocks/spys and side-effects and async code. I also think the concept is perhaps tricky to unify with react-testing-library, which is more interested in testing a section of the component tree rather than specific unit tests.

Gatsby

I’ve been keeping up with what has been happening in the Gatsby universe, given the time constrains of my current role I have often been a few months behind the webinars, but the advancements in V4 and the plugin/cloud architecture look to seriously impressive. I’ve yet to really delve into Gatsby Cloud Functions (which actually released in late V3), Server Side Rendering (SSR) or the Deferred Static Generation (DSG). These features sound incredibly useful and I’m hoping to make more use of them soon. I’m hoping to write a post soon going into more detail on my experiences of GatsbyV4.

Final Thoughts.

I need to write more blog posts via the WP CMS, hopefully there are going to be more frequent blog posts!