Chapter quiz · Building REST APIs

Test what you learned.

8 questions on Building REST APIs. Pass 70% to clear the chapter.

← Review chapter lessons

Quiz

Building a REST API — Chapter Quiz

Eight questions on koa-bodyparser, controllers/services split, validation 422, pagination, content negotiation, ctx.throw, and versioning.

0/ 9
  1. Question 1
    1

    After adding koa-bodyparser middleware, where does Koa place the parsed JSON request body?

  2. Question 2
    2

    Which HTTP status code should be returned when a request body fails validation?

  3. Question 3
    3

    How does ctx.throw(404, 'Not found') differ from throw new Error('Not found')?

  4. Question 4
    4

    What is a simple cursor-based or offset/limit pagination response envelope?

  5. Question 5
    5

    How do you implement API versioning via URL path in a Koa app using @koa/router?

  6. Question 6
    6

    Content negotiation via ctx.accepts('json', 'html') returns the best match from the Accept header, or false if none match.

  7. Question 7
    7

    A controller should delegate business logic to a ___ layer, keeping route handlers thin.

  8. Question 8
    8

    Which practices improve a Koa REST API's reliability and maintainability?

    Select all that apply.

Pick an answer — instant feedback as you go.