Skip to content

Abhinav kitchen inventory management create backend api endpoints to get events to the calendar#2082

Open
abhinav-TB wants to merge 3 commits intodevelopmentfrom
Abhinav-Kitchen-Inventory-Management-Create-Backend-API-endpoints-to-get-events-to-the-calendar
Open

Abhinav kitchen inventory management create backend api endpoints to get events to the calendar#2082
abhinav-TB wants to merge 3 commits intodevelopmentfrom
Abhinav-Kitchen-Inventory-Management-Create-Backend-API-endpoints-to-get-events-to-the-calendar

Conversation

@abhinav-TB
Copy link
Member

Description

Implements backend API endpoints for the Kitchen Inventory Calendar feature. These endpoints allow the frontend calendar to retrieve, create, and delete events across Garden, Orchard, Animals, and Kitchen modules, filtered by month/year and optional module.

Implements # Kitchen Inventory Management - Create Backend API endpoints to get events to the calendar

Related PRs (if any):

This is a backend-only PR.

Main changes explained:

  • Create calendarEvent.js — Unified Mongoose model for calendar events with fields: title, module (garden/orchard/animals/kitchen), event_type, scheduled_date, description, assigned_to, related_item, and status
  • Create calendarController.js — Controller with three methods:
    • getCalendarEvents — GET events filtered by month/year, optional module filter, merges kitchen events from ProcessingProject collection
    • createEvent — POST to create a new calendar event with validation
    • deleteEvent — DELETE an event by ID
  • Create calendarRouter.js — Router with GET/POST on / and DELETE on /:id
  • Update routes.js — Registered calendarEvent model and calendarRouter at /api/kitchenandinventory/calendar

How to test:

  1. Check out this backend branch: Abhinav-Kitchen-Inventory-Management-Create-Backend-API-endpoints-to-get-events-to-the-calendar
  2. Run npm install and npm run dev
  3. Open Postman and log in via POST /api/login with admin credentials to get a JWT token
  4. Set the Authorization header with the token for all following requests
  5. Test POST — Create an event:
    POST /api/kitchenandinventory/calendar Body: { "title": "Strawberry Seeding", "module": "garden", "event_type": "seeding", "scheduled_date": "2026-03-15", "description": "Plant strawberry seeds in greenhouse", "assigned_to": "Garden Team", "related_item": "Strawberry Seeds" } Verify 201 response with the created event
  6. Test GET (all events)GET /api/kitchenandinventory/calendar?month=3&year=2026 — verify the event appears in the response
  7. Test GET (filtered)GET /api/kitchenandinventory/calendar?month=3&year=2026&module=garden — verify only garden events are returned
  8. Test DELETEDELETE /api/kitchenandinventory/calendar/<event_id> — use the _id from step 5, verify 200 response
  9. Test validationGET /api/kitchenandinventory/calendar (no params) — verify 400 error
  10. Test invalid moduleGET /api/kitchenandinventory/calendar?month=3&year=2026&module=invalid — verify 400 error

Screenshots or videos of changes:

2026-02-28_12-02-44 2026-02-28_12-03-43 2026-02-28_12-03-59

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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