All practice tasks

Coding (Platform)

Upload command ownership

nestjs · Medium · upload lifecycle

A production API needs a upload command ownership repair at its service boundary. A React upload panel lets the user replace a file while the previous upload is still running. Progress and completion from the old upload currently overwrite the new file.

Task

Implement the upload command ownership contract used by the supplied HTTP adapter. Reduce choose, progress, complete, fail and remove events so only the current upload owns visible state.

Contract

Input is {events}. choose carries id and name; other events carry id. Return {fileName,progress,status,error,aborted}.

Acceptance criteria

  • Choosing a file aborts the previous active ID.
  • Ignore stale progress and settlements.
  • Clamp current progress to 0..100.
  • Remove aborts current work and clears visible state.
  • Return a deterministic JSON-serializable result for the HTTP adapter.

Constraints

  • Do not mutate caller-owned input.
  • Keep the supplied framework adapter and public contract unchanged.
  • Add candidate tests for at least one boundary not covered by the public cases.

Editable files

  • src/repair.js — Task-specific state or service boundary
  • tests/candidate.test.js — Candidate-authored regression

What this task practices

Upload command ownership is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on State Modeling, Regression Testing, Technical Reasoning. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.