Thu 26-09-2024 by benjamin
I started this week learning about server file security. This was helpful to consider as it had not crossed my mind, I had config files with sensitive information available to the user through the url. This gave me a good task to learn a bit more about apache configuration, and reinforce my knowledge of docker. The solution in my project uses a virtual host. Virtual hosts would allow multiple sites to run on one IP address but for the context of my blog site it is being used to neatly hold the config, document root settings and access permission for the whole blog site (an improvement on my previous solution of just blocking each file individually in the apache config). In creating a JSON repository last week I created the shell of a JSON API, so as an intro to JSON APIs I polished the endpoints and authentication for this system. I read a fair bit on API structure, learning how authentication should work. RESTful APIs should not retain session so endpoints that require authentication can do so via a token. I looked at bearer tokens, a server generated string of random characters that gives the bearer access to an endpoint, and implemented this in my API. This task also gave me a good opportunity to play around with postman, I now have a good understanding of how to test endpoints using postman (ie. using headers and adding authentication). I had a go at a slightly more complex tailwind feature, in styling a full customised radio button. My approach was to set the radio opacity to zero and place it within a styled label. I learnt a bit more about pseudo classes in tailwind, specifically the 'has' class that I used to style the label differently when the radio was checked. <label class="bg-blue-200 has-[:checked]:bg-blue-500"> <span>all</span> <input type="radio" value="all" class="opacity-0"> </label> On tuesday/wednesday I spent a bit of time reading through refactoring guru articles on builder/director class design patterns, with the goal of creating my own SearchBuilder class to use when filtering my homepage. A search object could contain many different properties depending on what filters and searches you apply, this would lead to a very large and messy construction method. A builder object contains helper methods to build each of the properties its corresponding object could contain, thus no unneeded properties need be constructed. A director class knows how to create specific types of an object and will call the builder method as required.