Skip to content

Commit b8d356f

Browse files
authored
Final update Readme - fix few typos
1 parent df03b55 commit b8d356f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
<a href="https://minimal-fastapi-postgres-template.rafsaf.pl/" target="_blank">
2+
<img src="https://img.shields.io/badge/live%20example-https%3A%2F%2Fminimal--fastapi--postgres--template.rafsaf.pl-blueviolet" alt="Live example">
3+
</a>
14
<a href="https://github.com/rafsaf/minimal-fastapi-postgres-template/blob/main/LICENSE" target="_blank">
25
<img src="https://img.shields.io/github/license/rafsaf/minimal-fastapi-postgres-template" alt="License">
36
</a>
4-
<img src="https://img.shields.io/badge/python-3.10-blue" alt="Python">
5-
<img src="https://img.shields.io/badge/code%20style-black-lightgrey" alt="Black">
6-
<a href="https://minimal-fastapi-postgres-template.rafsaf.pl/" target="_blank">
7-
<img src="https://img.shields.io/badge/live%20example-https%3A%2F%2Fminimal--fastapi--postgres--template.rafsaf.pl-blueviolet" alt="Live example">
7+
<a href="https://docs.python.org/3/whatsnew/3.10.html" target="_blank">
8+
<img src="https://img.shields.io/badge/python-3.10-blue" alt="Python">
9+
</a>
10+
<a href="https://github.com/psf/black" target="_blank">
11+
<img src="https://img.shields.io/badge/code%20style-black-lightgrey" alt="Black">
812
</a>
913
<a href="https://github.com/rafsaf/minimal-fastapi-postgres-template/actions/workflows/tests.yml" target="_blank">
1014
<img src="https://github.com/rafsaf/minimal-fastapi-postgres-template/workflows/tests/badge.svg" alt="Tests">
@@ -35,6 +39,8 @@
3539
- [x] `pre-push.sh` script with poetry export, autoflake, black, isort and flake8
3640
- [x] Rich setup for pytest async tests with few included and extensible `conftest.py`
3741

42+
<br>
43+
3844
_Check out also online example: https://minimal-fastapi-postgres-template.rafsaf.pl, it's 100% code used in template with added domain and https only._
3945

4046
![template-fastapi-minimal-openapi-example](./docs/template-minimal-openapi-example.png)
@@ -65,7 +71,7 @@ uvicorn app.main:app --reload
6571
# Optionally - use git init to initialize git repository
6672
```
6773

68-
### Running tests
74+
#### Running tests
6975

7076
```bash
7177
# Note, it will use second database declared in docker-compose.yml, not default one
@@ -84,11 +90,13 @@ pytest
8490
# ======================================================== 7 passed in 1.75s ========================================================
8591
```
8692

93+
<br>
94+
8795
## About
8896

8997
This project is heavily based on the official template https://github.com/tiangolo/full-stack-fastapi-postgresql (and on my previous work: [link1](https://github.com/rafsaf/fastapi-plan), [link2](https://github.com/rafsaf/docker-fastapi-projects)), but as it now not too much up-to-date, it is much easier to create new one than change official. I didn't like some of conventions over there also (`crud` and `db` folders for example or `schemas` with bunch of files).
9098

91-
`2.0` style SQLAlchemy API is good enough so there is no need to write everything in `crud` and waste our time... The `core` folder was also rewritten. There is great base for writting tests in `tests`, but I didn't want to write hundreds of them, I noticed that usually after changes in the structure of the project, auto tests are useless and you have to write them from scratch anyway (delete old ones...), hence less than more. Similarly with the `User` model, it is very modest, with just id, email and password, because it will be adapted to the project anyway.
99+
`2.0` style SQLAlchemy API is good enough so there is no need to write everything in `crud` and waste our time... The `core` folder was also rewritten. There is great base for writting tests in `tests`, but I didn't want to write hundreds of them, I noticed that usually after changes in the structure of the project, auto tests are useless and you have to write them from scratch anyway (delete old ones...), hence less than more. Similarly with the `User` model, it is very modest, with just `id` (uuid), `email` and `password_hash`, because it will be adapted to the project anyway.
92100

93101
<br>
94102

@@ -153,7 +161,7 @@ class Pet:
153161

154162
```
155163

156-
Note, we are using super powerful SQLAlchemy feature here - you can read more about this fairy new syntax based on dataclasses [in this topic in docs](https://docs.sqlalchemy.org/en/14/orm/declarative_styles.html#example-two-dataclasses-with-declarative-table).
164+
Note, we are using super powerful SQLAlchemy feature here - you can read more about this fairy new syntax based on dataclasses [in this topic in the docs](https://docs.sqlalchemy.org/en/14/orm/declarative_styles.html#example-two-dataclasses-with-declarative-table).
157165

158166
<br>
159167

@@ -185,9 +193,9 @@ PS. Note, alembic is configured in a way that it work with async setup and also
185193

186194
### 3. Create request and response schemas
187195

188-
Note, I personally lately (after seeing clear benefits at work) don't prefer less file than more for things like schemas.
196+
Note, I personally lately (after seeing clear benefits at work) prefer less files than a lot of them for things like schemas.
189197

190-
Thats why there are only 2 files: `requests.py` and `responses.py` in `schemas` and I would keep it that way even for few dozen of endpoints.
198+
Thats why there are only 2 files: `requests.py` and `responses.py` in `schemas` folder and I would keep it that way even for few dozen of endpoints.
191199

192200
```python
193201
# app/schemas/requests.py
@@ -252,7 +260,7 @@ async def get_all_my_pets(
252260
session: AsyncSession = Depends(deps.get_session),
253261
current_user: User = Depends(deps.get_current_user),
254262
):
255-
"""Creates new pet. Only for logged users."""
263+
"""Get list of pets for currently logged user."""
256264

257265
pets = await session.execute(
258266
select(Pet)
@@ -285,8 +293,6 @@ api_router.include_router(pets.router, prefix="/pets", tags=["pets"])
285293

286294
### 5. Write tests
287295

288-
No
289-
290296
```python
291297
# /app/tests/test_pets.py
292298

0 commit comments

Comments
 (0)