moving from rehype converting markdown to html, to the MarkdownPreview component from react-markdown-preview - I did this change as my markdown editor had a ton of features, such as copying code blocks , which were not in the rehype plugin.
moving from postgres nest to supabase - I did this after an hour into setting up nest, as my friend suggested supabase to me and I realized its much easier to use
making the entire auth process work for everyone - Before, the authentication process was only for admins, and after realizing it needs to be for everyone so it supports the commenting feature, I had to change stuff like the navbar, dropdown, the middleware.
moving from my old form system to react-hook-form - My old form system worked for a while, but to do validations for each input it was not a viable option - thus I switched to react-hook-form.
Blog API
At the time of this journal, I have spent 11 hours on the backend, with 24 commits.
APIs
/posts
/: Gets all posts
/:slug: Gets the post with the given slug
/:id/comment: Adds comment to the given post from the given user
/:id/comments: Gets all comments on the given post
/admin
/createPost: Creates a Post with the given fields
/editPost: Edits a given post with the given fields
/deletePost: Deletes a given post
/stats: Gets total reading time and total words of all posts
/auth
/register: Registers a new user with the given details and sets session
/login: Logins a new user with the given details and sets session
/me: Gets current session
/logout: Destroys current session
/edit: Edits user with given details
/comments
/:id/edit: Edits a given comment with given details
/:id/delete: Deletes a given comment
Stuff that I did, but later on had to change are
moving from javascript to typescript - Javascript worked at first, but I later on needed types - explaining the switch.
making error handling better - Before, for every server errors I handled them at each route, this lead to many repetitive lines so I moved them to app.ts and called next() if I got a server error
auth middleware - Instead of checking if the user is authed/an admin in every route, I made a middleware which can be set to auth only/admin only routes.
I have deployed both the frontend and the API to vercel, which took me around an hour.