Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Oct 18, 2024
1 parent 2122def commit 5995e4f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
41 changes: 36 additions & 5 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/docs/views/templates/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Templates overview

0 comments on commit 5995e4f

Please sign in to comment.