Skip to content

Fix Interface names, controller error handling, and RESTful API endpoints#53

Open
Copilot wants to merge 11 commits into
masterfrom
copilot/fix-interface-names
Open

Fix Interface names, controller error handling, and RESTful API endpoints#53
Copilot wants to merge 11 commits into
masterfrom
copilot/fix-interface-names

Conversation

Copy link
Copy Markdown

Copilot AI commented May 6, 2026

Swap Repository/Service interface and class names to correct layering pattern, add proper error handling to controllers, and adjust all endpoints to follow RESTful API best practices.

Changes Made

  • Swapped Repository/Service interface and class names to correct layering pattern
  • Updated all consumers: Controllers, DI registrations, cross-references
  • Updated test files: renamed test classes, moved between folders, fixed namespaces
  • Added try-catch blocks to all controller action methods with proper HTTP status codes (401, 409, 400, 404, 500)
  • Auth-specific exceptions only caught in AuthController; non-auth controllers catch only domain-relevant exceptions
  • Added new domain-specific exceptions: InterviewSessionNotFoundException, InterviewNotFoundException, DataValidationException
  • InterviewSessionRepository throws InterviewSessionNotFoundException for null results
  • UserRepository.ValidateUpdateUserDataAsync uses DataValidationException instead of auth exceptions
  • Removed all controller test files (AuthControllerTest, InterviewControllerTest, InterviewSessionControllerTest, UserControllerTest, ProfilePictureControllerTest)
  • Adjusted all endpoints to follow RESTful API best practices:
    • Routes use plural nouns and lowercase kebab-case (api/users, api/interviews, api/interview-sessions, api/profile-pictures)
    • Removed verbs from URLs — HTTP methods convey the action (e.g., GET api/users/me instead of GET api/User/get-current-user)
    • Resource hierarchy for sub-resources (api/interviews/hr, api/interviews/technical, api/interview-sessions/statistics)
    • Changed profile picture update from POST to PUT (replacing a resource)
    • Updated frontend endpoint definitions to match new backend routes
  • All 109 remaining service/repository tests pass

Copilot AI linked an issue May 6, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 6, 2026 19:14
…rect Controller -> Service -> Repository pattern

Agent-Logs-Url: https://github.com/P1l3T0/prepAIred/sessions/5d4506c8-b4da-4254-b0bc-e8a75055aa27

Co-authored-by: P1l3T0 <95146724+P1l3T0@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix interface names in backend structure Fix Interface names: swap Repository and Service naming to correct layering pattern May 6, 2026
Copilot AI requested a review from P1l3T0 May 6, 2026 19:16
Copilot finished work on behalf of P1l3T0 May 6, 2026 19:16
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 6, 2026

@copilot the code inside the controllers must be in a try catch block

Copy link
Copy Markdown
Author

Copilot AI commented May 6, 2026

@copilot the code inside the controllers must be in a try catch block

Done in 8357e5b. All controller action methods are now wrapped in try-catch blocks that re-throw exceptions to be handled by the GlobalExceptionHandler.

Copilot finished work on behalf of P1l3T0 May 6, 2026 19:23
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 6, 2026

@copilot throw the actual errors, not just add the throw keyword

Copy link
Copy Markdown
Author

Copilot AI commented May 6, 2026

@copilot throw the actual errors, not just add the throw keyword

Updated in 03aec1e. All catch blocks now capture the exception in a variable and throw it explicitly: catch (Exception ex) { throw ex; }.

Copilot finished work on behalf of P1l3T0 May 6, 2026 19:28
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 7, 2026

@copilot for the controllers, they should return the corresponding HTTP status code based on the success or failure of the operation, adjust them accordingly, especially the Authentication related ones

Copy link
Copy Markdown
Author

Copilot AI commented May 7, 2026

@copilot for the controllers, they should return the corresponding HTTP status code based on the success or failure of the operation, adjust them accordingly, especially the Authentication related one...

Done in a5eebdf. All controllers now catch specific exceptions and return the corresponding HTTP status codes:

  • InvalidCredentialsException, NoUserLoggedInException, InvalidAccessTokenException, InvalidRefreshTokenException → 401 Unauthorized
  • UserAlreadyExistsException → 409 Conflict
  • EmptyFieldsException, UnsupportedFileExtensionException, ProfilePictureException → 400 Bad Request
  • ResourceNotFoundException → 404 Not Found
  • Generic Exception → 500 Internal Server Error

Copilot finished work on behalf of P1l3T0 May 7, 2026 07:48
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 7, 2026

@copilot You didn't understand, I meant I want auth-related exceptions for the auth controller only, for the others i do not want the following in them, because they are not related to authentication at all:

catch (InvalidCredentialsException ex)
{
    return Unauthorized(ex.Message);
}
catch (UserAlreadyExistsException ex)
{
    return Conflict(ex.Message);
}
catch (EmptyFieldsException ex)
{
    return BadRequest(ex.Message);
}

Now review what the services do and the current custom exceptions and try to add new custom exceptions to the services/repositories if you find any use for them

Copilot AI and others added 2 commits May 7, 2026 08:09
…ontrollers, add domain-specific exceptions

Agent-Logs-Url: https://github.com/P1l3T0/prepAIred/sessions/273899e2-0cf5-481f-a08e-d530b942064c

Co-authored-by: P1l3T0 <95146724+P1l3T0@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented May 7, 2026

@copilot You didn't understand, I meant I want auth-related exceptions for the auth controller only, for the others i do not want the following in them, because they are not related to authentication ...

Done in b76f146 and ce9a73a.

Changes made:

  • Removed InvalidCredentialsException, UserAlreadyExistsException, and EmptyFieldsException catches from all non-auth controllers (InterviewController, InterviewSessionController, UserController, ProfilePictureController)
  • Added new domain-specific exceptions: InterviewSessionNotFoundException, InterviewNotFoundException, DataValidationException
  • InterviewSessionRepository now throws InterviewSessionNotFoundException when sessions are not found (GetAdjacentInterviewSessionAsync, GetInterviewSessionByIdAsync, GetInterviewSessionFromQuestionsAsync)
  • UserRepository.ValidateUpdateUserDataAsync now throws DataValidationException instead of auth-related exceptions
  • Each controller only catches exceptions relevant to its domain:
    • AuthController: InvalidCredentialsException, UserAlreadyExistsException, EmptyFieldsException, InvalidRefreshTokenException, NoUserLoggedInException
    • InterviewController: InterviewSessionNotFoundException, ResourceNotFoundException
    • InterviewSessionController: InterviewSessionNotFoundException
    • UserController: DataValidationException, ResourceNotFoundException
    • ProfilePictureController: UnsupportedFileExtensionException, ProfilePictureException

Copilot finished work on behalf of P1l3T0 May 7, 2026 08:13
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 7, 2026

@copilot okay cool, now I want you to remove all tests related to the only the controllers, leave the rest

Copy link
Copy Markdown
Author

Copilot AI commented May 7, 2026

@copilot okay cool, now I want you to remove all tests related to the only the controllers, leave the rest

Done in f73081d. Removed all 5 controller test files (AuthControllerTest, InterviewControllerTest, InterviewSessionControllerTest, UserControllerTest, ProfilePictureControllerTest). The remaining 109 service/repository tests all pass.

Copilot finished work on behalf of P1l3T0 May 7, 2026 08:20
@P1l3T0 P1l3T0 marked this pull request as ready for review May 9, 2026 15:06
@P1l3T0
Copy link
Copy Markdown
Owner

P1l3T0 commented May 11, 2026

@copilot adjsut the endpoints to follow the best practices for RESTful APIs

Copy link
Copy Markdown
Author

Copilot AI commented May 11, 2026

@copilot adjsut the endpoints to follow the best practices for RESTful APIs

Done in c1622fd. All endpoints now follow RESTful best practices:

  • Routes: plural nouns, lowercase kebab-case (api/users, api/interviews, api/interview-sessions, api/profile-pictures)
  • No verbs in URLs: HTTP methods convey the action (e.g., GET api/users/me instead of GET api/User/get-current-user)
  • Resource hierarchy: api/interviews/hr, api/interviews/technical, api/interview-sessions/statistics, etc.
  • Proper HTTP methods: profile picture update changed from POST to PUT
  • Frontend endpoints updated to match

Copilot AI changed the title Fix Interface names: swap Repository and Service naming to correct layering pattern Fix Interface names, controller error handling, and RESTful API endpoints May 11, 2026
Copilot finished work on behalf of P1l3T0 May 11, 2026 18:16
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.

Fix Interface names.

2 participants