Some changes I made to the back end involved updating the validation to ensure that the form data to create an author or book is not empty. This was necessary because initially when I submitted the form to create a book or author it was allowing me to create books with empty titles, and authors with empty names. I also had to add some logic that parses integers from the request body, because apparently, you can only send numbers over http as a string, and then they need to be converted back to a number on the server side. I also added routers to make adding the `/api` to the start of the API route a little bit easier. If I could go back in time, I would have added these changes before building the UI.
I only used server side validation, as in this case it was sufficient on it's own. The pros of making client-side validation is that it puts less load on the server, because invalid requests are filtered before even being sent to the API. The con to client-side validation is that it's insufficient on it's own, because someone could always just hit the API directly using curl or postman, and the client-side validation would be rendered useless. The pro of server-side validation is that it always stops bad data from reaching the database even if the user uses curl or postman to circumvent the API. In this way, client-side validation is optional, however server-side validation is not.
I enjoyed using React. I found the process of creating components and screens easy to work with. I found it satisfying being able to have a reusable header (as opposed to copy and pasting one for a vanilla HTML website). I also found routing to be intuitive. One thing I struggled with was complying with typing. When I recieved a response from the database, and stored it to state, I had to create an interfacing matching the expected data format received from the database and explicitly define it in the `useState` declaration or else React would assume I was working with a `never` type because the state starts off as an empty array.
Writing React was much more succinct and overall a much better experience. As mentioned before, I really enjoyed the ability to reuse the header component so that I didn't need to copy and paste as much. I also found that managing state was initially a little harder because of the need to use a setter function, but all in all, I know that when the app's codebase gets bigger it will save more headache in the long-run. I definately prefer writing React.
Types were definately useful, but they were annoying at times. Like I mentioned before, when recieving data from the API, I needed to create custom datatypes to outline what the expected data would look like. The most annoying thing was that useState kept assuming any state that starts with a value of `[]` is of type `never[]`. I guess it makes sense because React can't know from that initial value what the underlying array type is, it just would've made my life easier if it defaulted to `any[]` instead, though I also understand why React choses not to do that, as to not let me (the programmer) be lazy about types. Other than that minor annoyance though, I didn't struggle with typing.
No
N/A