Description:
Currently, PostController handles both public post display (listing, single post) and authenticated post management (my posts, create, amend, delete). This mixes responsibilities and can be cleaner.
Proposed Refactor:
1. Controllers:
2. Service:
Keep a single PostService class to handle all post operations, both read and write.
Methods can stay logically grouped as read vs write internally.
3. Routes:
Public routes remain in PostController.
Authenticated routes are moved to PostManagementController with proper middlewares (Editor, Owner).
Description:
Currently,
PostControllerhandles both public post display (listing, single post) and authenticated post management (my posts, create, amend, delete). This mixes responsibilities and can be cleaner.Proposed Refactor:
1. Controllers:
PostController→ handles public-facing post display only:posts()– paginated list of postspost()– single post viewPostManagementController→ handles authenticated management only:myPosts()createFrom(),create()amendForm(),amend()delete(),deleteImage()2. Service:
Keep a single
PostServiceclass to handle all post operations, both read and write.Methods can stay logically grouped as read vs write internally.
3. Routes:
Public routes remain in
PostController.Authenticated routes are moved to
PostManagementControllerwith proper middlewares (Editor,Owner).