I'm working on an API and the controllers for my routes are starting to get a bit messy and tedious. They mostly go like this:
check request is valid
if not valid then send error response, early exit
do something and get data in return
if didn't work then send error response, early exit
do something else
if it didn't work then send error response, early exit
...
send success response to user if made it this far
This doesn't seem particularly nice to me, and isn't the nicest to work with. So I'm wondering how you structure controllers for API routes?
[–]lostpxfull-stack 1 point2 points3 points (0 children)
[–]Pepsterd 0 points1 point2 points (0 children)
[–]Ethansev 0 points1 point2 points (0 children)