Conversation
Lets foster coordinators recommend a Chameleon animal to a volunteer before a formal match exists. New recommendations default to isActive: true and the endpoint returns 200 with the created row. - CreateRecommendationDTO validates volunteerId and chameleonAnimalId as positive integers; the controller re-checks with validateId so the guard holds when the handler is called directly - 404 when the volunteer does not exist, via VolunteersService.existsById - validateId now rejects non-integers, which the "valid integer" rule needs - Registers RecommendationsModule on the app module Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Code review caught that registering RecommendationsModule made the app fail to boot. It pulls in VolunteersModule, the first forFeature module reachable from AppModule, so autoLoadEntities handed TypeORM FosterVolunteer without FosterCoordinator - which its assignedCoordinator relation targets - and metadata building threw before app.listen. No test caught it because none stand up the module graph. - VolunteersModule now imports CoordinatorsModule, so it is self-contained wherever it is registered rather than relying on the app module - recommendations.module.spec asserts the entity graph reachable from the module is closed under relations; it fails without the fix above - Service upserts on the composite key instead of save(), so two coordinators recommending the same animal at once cannot race into a primary key violation surfacing as a 500 - Pin the 200 status the ticket requires, so dropping @httpcode fails Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Juwang110
marked this pull request as ready for review
September 27, 2026 17:44
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ℹ️ Issue
Closes MSPCA-11
📝 Description
Adds
POST /api/recommendations, which lets a foster coordinator recommend a Chameleon animal to a volunteer before a formal match exists. The body is{ volunteerId, chameleonAnimalId }, and the endpoint returns 200 with the saved recommendation (isActive: true). It returns 400 when either ID is missing or isn't a positive integer, and 404 when the volunteer doesn't exist.Changes:
CreateRecommendationDTO,RecommendationsService.create, and the controller route. The route uses@HttpCode(200)because the ticket asks for 200 and Nest's default for POST is 201.VolunteersService.existsByIdfor the 404 check.RecommendationsModulenow importsVolunteersModule, and it's registered inAppModule.createupserts on the(volunteer_id, chameleon_animal_id)primary key. Recommending the same animal twice reactivates the existing row instead of failing with a PK violation, even when two coordinators do it at the same time.validateIdnow usesNumber.isInteger, so1.5andundefinedare rejected.VolunteersModulenow importsCoordinatorsModule. Without it, registeringFosterVolunteerthroughautoLoadEntitiesmade the app fail on boot with "Entity metadata for FosterVolunteer#assignedCoordinator was not found".✔️ Verification
yarn test: all backend suites pass (20 suites, 160 tests). This covers new service and controller tests for success, the 404 case, each 400 case, and the 200 status code.yarn lint:check,yarn format:check, andtsc --noEmiton the backend are clean.isActive: true. A volunteer ID that doesn't exist should return 404, and a missing or non-integer ID should return 400.🏕️ (Optional) Future Work / Notes