You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/customization.qmd
+10-5Lines changed: 10 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,8 @@ The following fixtures, defined in `tests/conftest.py`, are available in the tes
25
25
-`set_up_database`: Sets up the test database before running the test suite by dropping all tables and recreating them to ensure a clean state.
26
26
-`session`: Provides a session for database operations in tests.
27
27
-`clean_db`: Cleans up the database tables before each test by deleting all entries in the `PasswordResetToken` and `User` tables.
28
-
-`client`: Provides a `TestClient` instance with the session fixture, overriding the `get_session` dependency to use the test session.
28
+
-`auth_client`: Provides a `TestClient` instance with access and refresh token cookies set, overriding the `get_session` dependency to use the `session` fixture.
29
+
-`unauth_client`: Provides a `TestClient` instance without authentication cookies set, overriding the `get_session` dependency to use the `session` fixture.
29
30
-`test_user`: Creates a test user in the database with a predefined name, email, and hashed password.
30
31
31
32
To run the tests, use these commands:
@@ -43,7 +44,7 @@ The project uses type annotations and mypy for static type checking. To run mypy
43
44
mypy
44
45
```
45
46
46
-
We find that mypy is an enormous time-saver, catching many errors early and greatly reducing time spent debugging unit tests. However, note that mypy requires you type annotate every variable, function, and method in your code base, so taking advantage of it is a lifestyle change!
47
+
We find that mypy is an enormous time-saver, catching many errors early and greatly reducing time spent debugging unit tests. However, note that mypy requires you type annotate every variable, function, and method in your code base, so taking advantage of it requires a lifestyle change!
47
48
48
49
### Developing with LLMs
49
50
@@ -84,15 +85,19 @@ We also create POST endpoints, which accept form submissions so the user can cre
84
85
85
86
#### Routing patterns in this template
86
87
87
-
In this template, GET routes are defined in the main entry point for the application, `main.py`. POST routes are organized into separate modules within the `routers/` directory. We name our GET routes using the convention `read_<name>`, where `<name>` is the name of the page, to indicate that they are read-only endpoints that do not modify the database.
88
+
In this template, GET routes are defined in the main entry point for the application, `main.py`. POST routes are organized into separate modules within the `routers/` directory.
89
+
90
+
We name our GET routes using the convention `read_<name>`, where `<name>` is the name of the page, to indicate that they are read-only endpoints that do not modify the database.
88
91
89
92
We divide our GET routes into authenticated and unauthenticated routes, using commented section headers in our code that look like this:
90
93
91
94
```python
92
95
# -- Authenticated Routes --
93
96
```
94
97
95
-
Some of our routes take request parameters, which we pass as keyword arguments to the route handler. These parameters should be type annotated for validation purposes. Some parameters are shared across all authenticated or unauthenticated routes, so we define them in the `common_authenticated_parameters` and `common_unauthenticated_parameters` dependencies defined in `main.py`.
98
+
Some of our routes take request parameters, which we pass as keyword arguments to the route handler. These parameters should be type annotated for validation purposes.
99
+
100
+
Some parameters are shared across all authenticated or unauthenticated routes, so we define them in the `common_authenticated_parameters` and `common_unauthenticated_parameters` dependencies defined in `main.py`.
In this example, the `welcome.html` template will receive two pieces of context: the user's `request`, which is always passed automatically by FastAPI, and a `username` variable, which we specify as "Alice". We can then use the `{{ username }}` syntax in the `welcome.html` template (or any of its parent or child templates) to insert the value into the HTML.
121
+
In this example, the `welcome.html` template will receive two pieces of context: the user's `request`, which is always passed automatically by FastAPI, and a `username` variable, which we specify as "Alice". We can then use the `{{{ username }}}` syntax in the `welcome.html` template (or any of its parent or child templates) to insert the value into the HTML.
Copy file name to clipboardExpand all lines: docs/installation.qmd
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ If you use VSCode with Docker to develop in a container, the following VSCode De
20
20
21
21
Simply create a `.devcontainer` folder in the root of the project and add a `devcontainer.json` file in the folder with the above content. VSCode may prompt you to install the Dev Container extension if you haven't already, and/or to open the project in a container. If not, you can manually select "Dev Containers: Reopen in Container" from View > Command Palette.
22
22
23
+
*IMPORTANT: If using this dev container configuration, you will need to set the `DB_HOST` environment variable to "host.docker.internal" in the `.env` file.*
24
+
23
25
## Install development dependencies manually
24
26
25
27
### Python and Docker
@@ -103,15 +105,32 @@ Set your desired database name, username, and password in the .env file.
103
105
104
106
To use password recovery, register a [Resend](https://resend.com/) account, verify a domain, get an API key, and paste the API key into the .env file.
105
107
108
+
If using the dev container configuration, you will need to set the `DB_HOST` environment variable to "host.docker.internal" in the .env file. Otherwise, set `DB_HOST` to "localhost" for local development. (In production, `DB_HOST` will be set to the hostname of the database server.)
109
+
106
110
## Start development database
107
111
112
+
To start the development database, run the following command in your terminal from the root directory:
113
+
108
114
```bash
109
115
docker compose up -d
110
116
```
111
117
118
+
If at any point you change the environment variables in the .env file, you will need to stop the database service *and tear down the volume*:
119
+
120
+
```bash
121
+
# Don't forget the -v flag to tear down the volume!
122
+
docker compose down -v
123
+
```
124
+
125
+
You may also need to restart the terminal session to pick up the new environment variables. You can also add the `--force-recreate` and `--build` flags to the startup command to ensure the container is rebuilt:
126
+
127
+
```bash
128
+
docker compose up -d --force-recreate --build
129
+
```
130
+
112
131
## Run the development server
113
132
114
-
Make sure the development database is running and tables and default permissions/roles are created first.
133
+
Before running the development server, make sure the development database is running and tables and default permissions/roles are created first. Then run the following command in your terminal from the root directory:
0 commit comments