Goals

Components on the server — design

Status: implemented are markup as HTML, components of the server, their results, Response going up, Content<T>, component values with a result, decorators with guards, wrappers that take the body and the request context, routes, and rooklang/server; the server of the site, site/server/main.rk, is written with them, and the guide has a section on them. The decisions are collected at the end of the document, together with what is not decided yet. Server markup, components and rooklang/server remain experimental in 1.x and may change between releases.

This document builds on components.md: components, decorators, context, components as values. It describes only what is different on the server.

  1. A backend is a tree of components. Middleware, a router, access checks and pages are components and decorators, as the views of the browser are. A request goes down the tree, and the value the tree gives becomes the response.
  2. Markup on the server is a string of HTML. The same tags, attributes and checks as in the browser, but <div> gives a string, with no DOM and no updates.
  3. Not only markup. A component of the server returns any value: HTML, a Response, data that becomes JSON. So the tree serves pages and an API alike.
  4. The language gives the means, not a framework. Routing, sessions and access are written in Rook with these means, as a library; the language has none of them built in.
  5. Types along the whole way, from the Request to the response, and readable JavaScript that runs in Node, Bun, Deno and Workers.

Markdown source on GitHub