Skip to main content

Practice ยท 2 of 3

Shared Contract

Write makeContract() returning { validateTask, toApiShape }: validateTask(body) returns { ok: true, value } when title is a non-empty string <= 200 and done is a boolean (missing done defaults false), else { ok: false, issues: [{field, message}] }; toApiShape(task) maps the internal { id, title, done, ownerId } to the public shape { id, title, done, author: ownerId } โ€” ownerId never leaves the server under its real name.

Difficulty: intermediate

Back to lesson: Practice: Full-Stack Integration โ€” Practice