As apps and data models get more complicated the need for proper planning increases. I spent a few hours in low-productivity fuckery incrementally adding things today until I realized it was getting a little out of hand and I need to sit down and do some proper planning.
It is interesting that there are two layers of planning now:
- Frontend planning: the structure of the clientside app implemented by React - what components are needed? what states are stored?
- Backend planning: the routing but also the structure of the api’s that are needed.
after so much practice in the last few days frontend planning is quite second nature to me (at least for SPA’s). Backend is where I am getting some confusion and so I will lay out the API structure needed.
- viewUser: when user is logged in, show what he has clicked on. if new user, create user
- addBarToUser: when user is logged in, add to barIDs
- removeBarFromUser: when user is logged in, remove bar from barIDs
- getClicks: given a barID, scan all users and list the users that match.
- User: userid, barIDs
- app.route(‘/api/clicks’).get(clickHandler.getClicks) // params req.query.barid
- app.route(‘/api/clicks/add’).get(clickHandler.addBarToUser) // params req.query.uid, barid
- app.route(‘/api/clicks/remove’).get(clickHandler.removeBarFromUser) // params req.query.uid, barid
app.route(‘/api/user’).get(clickHandler.viewUser) // params req.query.uid req.user.twitter.username
i like this structure rather than the two-model setup i made in the voting app. do more work in the user view rather than the bar view.
so today was one of those brick wall days. core of it was problems with running create-react-app alongside express routing when I dont truly understand every step and the black magic bit hard today. I couldnt figure out how to server a login.html file alongside the index.html file I normally serve. I have logged my problems here:
And these are the relevant resources I have found so far: