or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-6/

API Request Batch Processor

Build a batch processing utility that fetches data from multiple API endpoints simultaneously and reports on the success or failure of each request.

Requirements

Your utility should accept a list of API endpoint configurations and process all requests concurrently, tracking which ones succeed and which ones fail. The processor should:

  1. Accept an array of request configuration objects, where each object contains:

    • url: The API endpoint URL (string)
    • id: A unique identifier for the request (string)
  2. Make concurrent requests to all endpoints

  3. Wait for all requests to complete, regardless of success or failure

  4. Return a structured report containing:

    • successful: An array of objects with id and data properties for successful requests
    • failed: An array of objects with id and error properties for failed requests
    • summary: An object with successCount and failureCount properties

Behavior Specifications

  • All requests should be processed concurrently
  • The processor must wait for all requests to complete before returning results
  • Failed requests should not cause the entire batch to fail
  • The order of results in the report does not need to match the input order
  • Both successful and failed results must be captured and reported

Test Cases

Basic Success Case

  • Given three valid API endpoint configurations, when all endpoints return successful responses, then all three should appear in the successful responses array @test

Mixed Success and Failure

  • Given a mix of valid and invalid endpoint configurations, when some requests succeed and others fail, then successful responses should appear in the success array and failed ones in the failure array @test

All Failures Case

  • Given endpoint configurations that all result in errors, when all requests fail, then all should appear in the failed responses array and the success array should be empty @test

Implementation

@generates

API

/**
 * Processes multiple API requests concurrently and returns a report of results
 *
 * @param {Array<{url: string, id: string}>} requests - Array of request configurations
 * @returns {Promise<{successful: Array, failed: Array, summary: {successCount: number, failureCount: number}}>}
 */
async function processBatch(requests) {
  // IMPLEMENTATION HERE
}

module.exports = { processBatch };

Dependencies { .dependencies }

promise.allsettled { .dependency }

Provides promise settlement tracking functionality

node-fetch { .dependency }

Provides HTTP request capabilities