From 86889c2a00922006ff80cd50a567397ad14321cd Mon Sep 17 00:00:00 2001 From: Yerassyl Date: Thu, 11 Aug 2022 19:46:12 +0600 Subject: [PATCH] Fix typos & links --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d7068e0..59e54d2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ ## WIP: FastAPI Best Practices ### 1. Project Structure. Group files by module domain, not file types. -I don't like the project structure presented by @tiangolo, -where we separate file by their type (e.g. api, crud, models, schemas). -Structure that I find more scalable and evolvable is inspired by Netflix's [Dispatch](https://github.com/Netflix/dispatch_) with some little modifications. +I didn't like the project structure presented by @tiangolo, +where we separate files by their type (e.g. api, crud, models, schemas). +Structure that I find more scalable and evolvable is inspired by Netflix's [Dispatch](https://github.com/Netflix/dispatch) with some little modifications. ``` fastapi-project ├── alembic/ @@ -70,7 +70,7 @@ fastapi-project 9. `exceptions` - module specific exceptions, e.g. `PostNotFound`, `InvalidUserData` ### 2. Excessively use Pydantic -Pydantic has a rich set of feature to validate and transform data. +Pydantic has a rich set of features to validate and transform data. In addition to regular features like required, non-required fields and default data, it has built-in comprehensive data processing params like regex, enums for limited allowed options, length validation, email validation, etc. @@ -171,7 +171,7 @@ async def get_user_post(post: Mapping = Depends(valid_owned_post)): return post ``` -### 6. Decouple & reuse dependencies +### 6. Decouple & Reuse dependencies. Dependency calls are cached. Depdencies can be reused multiple times and they won't be recalculated - FastAPI caches their result by default, i.e. if we have dependency which calls service `get_post_by_id`, we won't be visiting DB each time we call this dependency - only the first time. @@ -267,4 +267,4 @@ it will return a nice response ### 28. don't forget that fastapi converts response Model to Dict then to Model then to JSON ### 29. if no async lib, and poor documentation, then use asgiref ### 30. use linters (black, isort, autoflake) -### 31. set logs from day 0 \ No newline at end of file +### 31. set logs from day 0