From 5995e4f4f5e1de662cdbc5cfc7a28eedb6ab7634 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Thu, 17 Oct 2024 19:11:14 -0700 Subject: [PATCH] docs --- docs/docs/configuration.md | 41 ++++++++++++++++++++++++++---- docs/docs/index.md | 2 +- docs/docs/views/templates/index.md | 1 + 3 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 docs/docs/views/templates/index.md diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index 679757ec..fe9c1589 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -4,7 +4,7 @@ Rwf supports file-based and environment-based configuration. The list of configu ## Enabling configuration -To configure Rwf, place a file called `rwf.toml` into the wording directory of your app. During development, this should be the root directory of your Cargo project. At startup, +To configure Rwf, place a file called `rwf.toml` into the working directory of your app. During development, this should be the root directory of your Cargo project. At startup, Rwf will automatically load configuration settings from that file, as they are needed by the application. ## Available settings @@ -16,16 +16,47 @@ section configures database connection settings, like the database URL, connecti ### `[general]` -| Setting | Description | Example | +| Setting | Description | Default | |---------|-------------|---------| -| `log_queries` | Toggles logging of all SQL queries executed by the [ORM](../models/). | `log_queries = true` | -| `secret_key` | Secret key, encoded using base64, used for [encryption](../encryption). | `secret_key = "..."` | +| `log_queries` | Toggles logging of all SQL queries executed by the [ORM](../models/). | `false` | +| `secret_key` | Secret key, encoded using base64, used for [encryption](../encryption). | Randomly generated | +| `cache_templates` | Toggle caching of [dynamic templates](/views/templates/). | `false` | #### Secret key The secret key is a base64-encoded string of randomly generated data. A valid secret key contains 256 bits of entropy and _must_ be generated using a [_secure_](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) random number generator. +If you have Python installed on your system, you can generate a secret key for Rwf in just a few lines of code: + +=== "Python" + ```python + import base64 + import secrets + + secret = base64.b64encode(secrets.token_bytes(int(256/8))) + print(secret) + ``` +=== "Output" + ``` + BJ3Og8l/Q8f+fLvQpb9CP7uUu/VG1/+CN2a1f/QyHWY= + ``` + !!! warning + Do not use this example key in production. Always generate a new one and keep it secret. + ### `[database]` -| Setting | Description | Example | +| Setting | Description | Default | |---------|-------------|---------| +| `name` | Name of the database to connect to. | Same as the `$USER` shell variable. If not set, default is `postgres`. | +| `user` | Name of the user to connect with to the database. | `$USER`, or `postgres` if not set. | +| `url` | Fully-qualified database connection string. | `postgresql://{user}/localhost:5432/{name}`, where `{user}` and `{name}` are `name` and `user` configuration values. | + +#### `url` + +The database URL was originally created by [The Twelve Factor App](https://12factor.net/) and uses the URL format for specifying database connections. It follows a standard format, as follows: + +``` +driver://user:password@host:port/database_name +``` + +For connecting to PostgreSQL, the `driver` is `postgresql` (or `postgres` is also acceptable). diff --git a/docs/docs/index.md b/docs/docs/index.md index 64d557b3..52ec0916 100644 --- a/docs/docs/index.md +++ b/docs/docs/index.md @@ -1,4 +1,4 @@ -# Introduction +# Getting started Rust Web Framework (Rwf for short) is set of libraries and tools to build web applications using the Rust programming langauge. It aims to be comprehensive, by providing all features for you to build modern, fast, and secure web apps, out of the box. diff --git a/docs/docs/views/templates/index.md b/docs/docs/views/templates/index.md new file mode 100644 index 00000000..95d30a04 --- /dev/null +++ b/docs/docs/views/templates/index.md @@ -0,0 +1 @@ +# Templates overview