Learn full-stack web development using fastn in a week
Learn Now

processor In fastn

ftd gives a way for its platform, fastn, to define some functions known as processors. These functions, then, can be used in the ftd, and their execution is handled by the platform.

At present, fastn contains the following processors:

All processors are defined in a module fastn/processor which must be imported to use any of these processors.
Static Vs Dynamic
This feature works better with dynamic hosting. If you are using fastn in static site mode, then how the page looked when fastn build was called will be shown to everyone. But if you are using dynamic mode then this page would be regenerated on every page load.


A processor is used when declaring a variable. The processor is in control of the variable if $processor$ key is used.
-- import: fastn/processors as pr

-- person list people:
$processor$: pr.package-query
db: db.sqlite


As you see $processor$ key was used when defining the variable called people. Once $processor$ is used, the rest of the section is in determined bu the specific processor used. Like in this case the processor pr.package-query expects a key named db, which refers to the database file, and the body of the section is the SQL query to execute against the database.

A processor must be used on a variable or a list with matching type as the output of the processor. In this case we are using SELECT * FROM user; so the columns of the user table must match the fields of the record person. Extra data will be ignored, but all required data must be passed for processor to work correctly.

The details of what the processor returns is documented as part of each processors documentation.

Planned: Custom Processors

fastn is planning to use wasmtime to let anyone write their own custom processors, which will allow much more functionalities.