Skip to content

API Endpoints Update Summary

Successfully updated the Bartendie router to include new API endpoints for event management. The system now supports RESTful operations for events using CQRS/Event Sourcing with Commanded.

  • GET /api/events - List all events (currently returns empty list, ready for read model implementation)
  • POST /api/events - Create a new event using CQRS commands
  • GET /api/events/:id - Get event details by ID (placeholder implementation)
  • GET /api/health - Health check endpoint
  • GET /api/info - API information endpoint
  1. lib/bartendie_web/controllers/event_controller.ex - Event API controller with CQRS integration
  2. lib/bartendie_web/controllers/fallback_controller.ex - Error handling for API responses
  3. lib/bartendie_web/controllers/changeset_json.ex - JSON rendering for validation errors
  4. test/bartendie_web/controllers/event_controller_test.exs - Unit tests for event endpoints
  5. test/support/conn_case.ex - Test support for controller tests
  6. test/support/data_case.ex - Test support for data layer tests
  7. test/test_helper.exs - Test configuration
  8. test_api_endpoints.exs - API testing script with curl examples
  1. lib/bartendie_web/router.ex - Added events resource routes
  2. lib/bartendie/application.ex - Added EventHandler to supervision tree
  • Events are created using Bartendie.Commands.CreateEvent command
  • Commands are dispatched through Bartendie.App (Commanded application)
  • Event handlers process domain events for side effects
  • Uses Commanded.UUID for generating unique identifiers
  • Comprehensive error handling with appropriate HTTP status codes
  • Validation error support through changeset JSON rendering
  • Fallback controller for consistent error responses
  • Unit tests verify endpoint functionality
  • Tests run without requiring full application startup
  • Includes tests for success and error scenarios
Terminal window
curl -X POST http://localhost:4000/api/events \
-H "Content-Type: application/json" \
-d '{"event": {"name": "Holiday Party", "date": "2024-12-25", "description": "Annual holiday celebration", "expected_guest_count": 50}}'
Terminal window
curl http://localhost:4000/api/events
Terminal window
curl http://localhost:4000/api/events/{event-id}
  1. Read Model Implementation - Implement projections to populate event listings
  2. Event Updates - Add PUT/PATCH endpoints for updating events
  3. Event Deletion - Add DELETE endpoint for removing events
  4. Validation - Add comprehensive input validation
  5. Authentication - Add authentication and authorization
  6. Additional Resources - Add endpoints for venues, menus, recipes, etc.
  • The system uses Phoenix 1.7+ with modern routing patterns
  • CORS is configured for frontend integration
  • LiveDashboard is available in development mode at /dev/dashboard
  • Event sourcing ensures full audit trail of all changes
  • The domain model supports complex bar management scenarios

Run tests with:

Terminal window
mix test test/bartendie_web/controllers/event_controller_test.exs

Start the server with:

Terminal window
mix phx.server

The API is now ready for frontend integration and further development.