Company: Stealth Health
Difficulty: medium
Problem Description Implement an API endpoint that processes a batch of ticket availability checks. In its original context, this problem simulated a generator processing an array of promises, yielding successful values and halting on the first rejection. To translate this to an API, your endpoint will receive a list of ticket objects and evaluate them sequentially. For each ticket: If the ticket's status is "available" , append its id to the results list. If the ticket's status is "unavailable" , append -1 to the results list and immediately stop processing any remaining tickets. The API should return the accumulated list of results. Endpoints POST /api/tickets/batch-check Request Format The request body must be a JSON object containing a tickets array. Each element in the array is an object representing a ticket to be checked. { "tickets": [ { "id": 10, "status": "available" }, { "id": 20, "status": "unavailable" } ] } Response Format Success Response (200 OK) Returns a JSON object w