Skip to content

Conversation

@NewdlDewdl
Copy link

@NewdlDewdl NewdlDewdl commented Oct 30, 2025

Target files:

  • api/controllers/course.go
  • api/controllers/professor.go
  • api/controllers/section.go

Goals:

  • Reduce code duplication
  • Improve maintainability
  • Ensure type safety
  • Maintain identical operational behavior

Work Completed

Changes Made

Created generic utility functions in controller_utils.go:

  • createContext() - Context creation with timeout
  • findAndRespond[T]() - Search endpoints with pagination
  • findOneByIdAndRespond[T]() - ById endpoints
  • findAllAndRespond[T]() - All endpoints
  • aggregateAndRespond[T]() - Aggregation pipelines

@NewdlDewdl NewdlDewdl changed the title Refactore controller files for improved organization and readability Refactor controllers to reduce boilerplate code Oct 30, 2025
@mikehquan19 mikehquan19 self-requested a review October 30, 2025 17:16
…fessors to improve readability and maintainability
@NewdlDewdl NewdlDewdl closed this Nov 7, 2025
@NewdlDewdl NewdlDewdl reopened this Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant