Repository navigation
bffc 34-stewards/admincan add plants to inventory - #65
Merged
saumyapalk23 merged 5 commits intoNov 22, 2026
Merged
Conversation
Adds a RolesGuard/@roles decorator (Cognito groups) for 403s, a validated CreateAdminEventDto, service logic that 404s on unknown sites and inserts into admin_events, extended response DTO, README docs and unit tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Returns the full plant record plus host sites via the site_plants join. Malformed ids return 400, unknown ids return 404.
Creates a plant and links it to sites through site_plants in a single transaction. Stewards can only link their own sites; admins can link any. Validates the request body, returns 404 for unknown site IDs, and stores empty optional text as null.
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 <#41>
📝 Description
Adds
POST /plantso stewards and admins can add plants to a site's inventory and link them to sites. A plant is saved ks, so the site page and plantview always show complete records.CreatePlantDto.nameis required.imageS3Key,description,flavor,harvestSeason,howToHarvest,re optional. Validation errorsname the field that failed (400).PlantsService.create, itssite_plantsrows in onetransaction. An unknown site ID returns 404. Empty optional fields come back as
null, anda plant with no sites returns `h
sites; admins can link any site.
✔️ Verification
✔️ Verification
yarn install.yarn test. All 245 testones inapps/backend/src/plants/.npx nx build backendan --base=main`. Both pass.SWAGGER_ENABLED=true, run the backend, and tryPOST /api/plantfrom Swagger at/api.no ui changes.
🏕️ (Optional) Future Work / Notes
piers/:id andRolesGuard`), so we gotta merge that PR first.with the site steward's email in Postgres. This only works becausecreateUsersets the username to the email. Storing the Cognitosubonusble link.