Tutorial: Stof + TypeScript Config
Simple, self-validating config using Stof + TypeScript
Defining a Simple Config & Testing in TypeScript
/*!
* Simple Server Config (Stof).
*/
// semantic versions are a primitive type in Stof
version: 0.1.0-server.example
server: {
name: "www.example.com:80"
root_dir: "/etc/httpd"
ms timeout: 3s
bool keep_alive: true
ms keep_alive_timeout: 5s
GiB ram: 32GiB
// single valid check to start
fn valid() -> bool {
self.ram > 2GiB &&
(!self.keep_alive || self.keep_alive_timeout > 100ms) &&
self.timeout > 100ms &&
self.name.len() > 0 &&
self.root_dir.len() > 0
}
}Apply the Server Config
Stof Endpoint Handler
Stof Schema & Type
Completed Example
Next Steps
Last updated