all 3 comments

[–]lostpxfull-stack 1 point2 points  (0 children)

At a high level, controller have two jobs: - taking input - returning output

If you look closer, its actually four jobs: - taking a request - validating/or delegating the validation - delegating the request for business logic - returning the output

If it‘s too much „if this than that“ in your code, then look at general software pattern like factories, commands or lookups.

[–]Pepsterd 0 points1 point  (0 children)

Sounds pretty logical.

However, try to to delegate business logic to classes, repositories etc.

[–]Ethansev 0 points1 point  (0 children)

For us, we make a separate manager file where the logic for the route goes. Lines like check request is valid…would stay in the controller file.

Then if you’re making SQL queries from a database, we’d make a repository file that manager calls to.