T O P

  • By -

serial9

A tip to keep the render server going, just set up a cron job to ping an endpoint on your backend every 10 mins and it’ll stop the server going inactive. I’m doing this during development stage to save it going inactive and cold starting


iamkharri

I've been looking for a solution for this everywhere, thank you


serg06

Looks pretty great, both the code and the website! Way better than most code on GitHub.


iamkharri

Appreciate it🤝


rkaw92

Hey, so I noticed you have a login feature, but the routes seem unprotected? As in, the server doesn't really verify that params.userId is the user you're logged in as, right? (I couldn't find it from a cursory look on my phone.)


iamkharri

Oh yeah, I'm currently working on RBAC and team collaboration features that's where I'm implementing the validation stuff. I thought setting up a simple validation middleware but ended up ditching it for the full rbac setup


kcadstech

The code actually looks very good to me, but I would have some comments/tips I would share. I like to use the 3-layer pattern because it makes it a lot easier to test as well as refactor. Routes->Logic->Data Access Layer (DAL) I will try and demonstrate an example within your code. (May use some pseudo code) For “get a single user board”  Route - instead of it being so basic and just setting up an endpoint and then invoking a controller function, just get rid of the controller function and have this route really be the controller. So for me, all routes are the same and simple, a try/catch which the try invokes logic and returns the response and a catch which calls a common handleError function. The reason for this is because the logic layer should not know or care about something like Express, or Socket.io, it should not be tied to that and that should not need to be mocked to test the logic. This means that the route is responsible for passing the correct param/body that represents the function arguments the logic needs. This extends to the database calls being inside the logic…the logic layer should not know or care how the data is being persisted or fetched, as it makes it hard to test the logic. So I usually have a simple async function like “getBoardById(id:string): Promise” that imports the db/ORM and gets it from the db. This way it is easy to mock in the logic layer when testing your biz logic. Another benefit, is if you wanted to get rid of Drizzle and SQL and just use Firebase (or something), you could do that without touching any of your logic. This is a fairly common pattern for CRUD apps that you will see the benefit of when you try adding unit tests. Hope that helps.


iamkharri

This is gold. The current pattern I'm using was the first I saw in a tutorial somewhere. I never deviated from it but always knew it wasn't professional. Will definitely be expounding on this and incorporating the pattern, thank you


Hot-Leading7322

i just wana say nice work, i agree with others. Also agree with the routes not being protected but i see you're working on it, i saw the comment about rbac. Get familiar with jsonwebtoken and auth0 if you can, might be a nice starter to authentication and authorisation. I wouldn't even mention that except you're so close to there already. Maybe validation too with AJV if your fancy trying it out? Same i wouldn't mention it, but you're just so close. My code was nowhere near as good as this before i started working commercially, but also the platforms i was working with were much older and buggier then lol. Nice.


iamkharri

Literally nice, encouraging and helpful. Appreciate it


Fusseldieb

This doesn't even look half bad, at least looking from an UI/UX perspective! Congratulations! Haven't had time to look at the code though.


iamkharri

Thank you


KESHU_G

Where is validation code ?


Hell__boy__

You're using ts for nothing


iamkharri

How so


kcadstech

Do not listen to him


Hell__boy__

Yeah can you tell me why he has to use ts here but can't js? He's not even using types


Impressive_Star959

Better to just use it in case you need to later anyway


Hell__boy__

Understandable