One door to the data

6:21 film

After this film you canput all data access in one server-only data access layer with verifySession.

Exercise

Download the exercise (a zip). Unzip it, read exercise.md, then in exercise/ run npm install and node check.mjs. The checker runs a real build and says PASS or FAIL for each criterion.

Recall

Answer each one out loud before you open it.

  1. Proxy let Bob's made-up cookie through. Why?

    It only checks that a cookie named session is there. It's a quick first pass, not the real check.

  2. Where does the real session check go, and why there?

    In the data access layer, next to the data. Every read goes through it, so the check comes with the data.

  3. The header and the orders list both call verifySession(). Why is the session looked up only once per render?

    verifySession is wrapped in React's cache(), which remembers the answer for that render.

Docs this film covers