Chapter quiz · Plugins, Hooks & Lifecycle

Test what you learned.

8 questions on Plugins, Hooks & Lifecycle. Pass 70% to clear the chapter.

← Review chapter lessons

Quiz

Plugins, Hooks & Lifecycle — Chapter Quiz

Eight questions on the plugin function signature, fastify-plugin, encapsulation, request and app hooks, decorators, and route prefixes.

0/ 9
  1. Question 1
    1

    What is the signature of a Fastify plugin?

  2. Question 2
    2

    Why wrap a plugin with fastify-plugin (fp)?

  3. Question 3
    3

    A hook registered inside a plugin runs for routes in that plugin's scope only, unless fastify-plugin wraps it.

  4. Question 4
    4

    Which hook runs **before** validation and the route handler, but **after** the request is parsed?

  5. Question 5
    5

    To run logic on the outgoing response, after the handler but before the bytes are sent, use the ____ hook.

  6. Question 6
    6

    What does app.decorate('db', client) do?

  7. Question 7
    7

    What URL does this route resolve to?

    await app.register(async (app) => {
      app.get('/users', async () => []);
    }, { prefix: '/api/v1' });
    
  8. Question 8
    8

    Which of these are request-lifecycle hooks in Fastify?

    Select all that apply.

Pick an answer — instant feedback as you go.