Event Controller for Satoshi Showdown. Manages HTTP requests for event-related operations such as creating, updating, retrieving, and deleting events. This controller acts as an intermediary between the client and the Event Service, handling the request and response cycle. It extracts necessary information from client requests, passes it to the Event Service for business logic processing, and then formats and returns responses.
- Source:
Requires
Methods
(async, inner) handleCastVote()
Controller for handling a user's vote in an event.
- Source:
(async, inner) handleCreateEvent(req, res, next) → {Promise.<void>}
Handles the creation of a new event. Validates user credentials and event data from the request body, invokes the Event Service to create a new event, and returns the details of the created event in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing event data and user credentials. |
res |
express.Response | Express response object for sending back the created event data. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If user validation fails or event creation encounters issues.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleDeleteEvent(req, res, next) → {Promise.<void>}
Handles deleting an event by its ID. Extracts the event ID from the request parameters, invokes the Event Service to delete the event, and sends a confirmation message upon successful deletion.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing the event ID. |
res |
express.Response | Express response object for sending back a deletion confirmation. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If the event deletion encounters issues or the event is not found.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleDetermineOutcome(req, res, next) → {Promise.<void>}
Handles determining the outcome of an event. Retrieves the event ID from the request parameters, invokes the Event Service to determine the outcome, and sends the outcome details in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing the event ID in parameters. |
res |
express.Response | Express response object for sending back the outcome data. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If the outcome determination encounters issues.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleGetAllEvents(req, res, next) → {Promise.<void>}
Handles retrieving all events from the system. Calls the Event Service to retrieve a list of all events and sends this data in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object. |
res |
express.Response | Express response object for sending back a list of all events. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If there's an issue retrieving the list of events.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleGetEvent(req, res, next) → {Promise.<void>}
Handles retrieving a specific event by its ID. Extracts the event ID from the request parameters, queries the Event Service to retrieve the event, and sends the event details in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing the event ID in parameters. |
res |
express.Response | Express response object for sending back the retrieved event data. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If the event is not found or there's an issue retrieving it.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleJoinEvent(req, res, next) → {Promise.<void>}
Handles a user joining an event. Extracts event and user IDs from the request, calls the Event Service to add the user to the event, and returns updated event details in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing event and user IDs. |
res |
express.Response | Express response object for sending back the updated event data. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If joining the event encounters issues.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>
(async, inner) handleSettleEvent()
Controller for handling the settlement of an event.
- Source:
(async, inner) handleUpdateEvent(req, res, next) → {Promise.<void>}
Handles updating an existing event. Extracts the event ID and update data from the request, calls the Event Service to apply the updates, and returns the updated event details in the response.
Parameters:
Name | Type | Description |
---|---|---|
req |
express.Request | Express request object containing event ID and update data. |
res |
express.Response | Express response object for sending back the updated event data. |
next |
express.NextFunction | Express next middleware function for error handling. |
- Source:
Throws:
-
If the event update encounters issues or the event is not found.
- Type
- Error
Returns:
No explicit return value, sends response to the client.
- Type
- Promise.<void>