Derive

Just like state and decorate, derive allows you to customize Context based on existing Context as Context.store.

This is useful when you need to create a value based on an existing value reactively.

Example

app
  .state("version", 1)
  .decorate("getDate", () => Date.now())
  .derive(({ request: { headers }, store, getDate }) => {
    return {
      authorization: headers.get("Authorization"),
    };
  })
  .get("/version", ({ authorization }) => authorization);
ON THIS PAGE