fastapi-basic 0.0.0__py3-none-any.whl → 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fastapi-basic might be problematic. Click here for more details.
- fastapi_basic/base_factory.py +14 -3
- fastapi_basic/utils.py +8 -0
- {fastapi_basic-0.0.0.dist-info → fastapi_basic-0.0.1.dist-info}/METADATA +10 -2
- fastapi_basic-0.0.1.dist-info/RECORD +8 -0
- fastapi_basic-0.0.0.dist-info/RECORD +0 -7
- {fastapi_basic-0.0.0.dist-info → fastapi_basic-0.0.1.dist-info}/WHEEL +0 -0
- {fastapi_basic-0.0.0.dist-info → fastapi_basic-0.0.1.dist-info}/top_level.txt +0 -0
fastapi_basic/base_factory.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
from abc import ABCMeta, abstractmethod
|
|
2
|
+
from functools import lru_cache
|
|
3
|
+
import os, dotenv
|
|
2
4
|
|
|
3
5
|
from fastapi import FastAPI
|
|
4
6
|
|
|
7
|
+
from .utils import update_dict_with_cast
|
|
8
|
+
|
|
5
9
|
class BaseFactory(metaclass=ABCMeta):
|
|
6
10
|
@abstractmethod
|
|
11
|
+
@lru_cache()
|
|
7
12
|
def get_app_config(self):
|
|
8
13
|
"""
|
|
9
14
|
Each factory should define what config it wants.
|
|
@@ -13,6 +18,12 @@ class BaseFactory(metaclass=ABCMeta):
|
|
|
13
18
|
"""
|
|
14
19
|
Create an application instance.
|
|
15
20
|
"""
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
21
|
+
self.__load_local_config()
|
|
22
|
+
app_config = self.get_app_config()
|
|
23
|
+
app = FastAPI(docs_url=app_config.get('DOCS_URL'), redoc_url=app_config.get('REDOC_URL'), openapi_url=app_config.get('OPENAPI_URL'))
|
|
24
|
+
app.state.config = app_config
|
|
25
|
+
return app
|
|
26
|
+
|
|
27
|
+
def __load_local_config(self):
|
|
28
|
+
dotenv.load_dotenv(override=True)
|
|
29
|
+
update_dict_with_cast(self.get_app_config(), os.environ)
|
fastapi_basic/utils.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
def update_dict_with_cast(curr_conf: dict, new_conf: dict):
|
|
4
|
+
for key in curr_conf.keys():
|
|
5
|
+
if key in new_conf:
|
|
6
|
+
key_type = type(curr_conf[key])
|
|
7
|
+
cast_func = key_type if key_type in (str, int) else json.loads
|
|
8
|
+
curr_conf[key] = cast_func(new_conf[key])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: fastapi_basic
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.1
|
|
4
4
|
Summary: A short description of your module
|
|
5
5
|
Home-page: https://github.com/szx21023/fastapi-base
|
|
6
6
|
Author: szx21023
|
|
@@ -22,6 +22,14 @@ Dynamic: requires-python
|
|
|
22
22
|
Dynamic: summary
|
|
23
23
|
|
|
24
24
|
# fastapi-base
|
|
25
|
-
|
|
25
|
+
how to release module
|
|
26
|
+
1. install relational modules
|
|
27
|
+
```
|
|
28
|
+
pip install setuptools wheel twine
|
|
29
|
+
```
|
|
30
|
+
2. modify setup.py(optional)
|
|
31
|
+
3. build env && upload to pypi
|
|
32
|
+
```
|
|
26
33
|
python setup.py sdist bdist_wheel
|
|
27
34
|
twine upload dist/*
|
|
35
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
fastapi_basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
fastapi_basic/base_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
fastapi_basic/base_factory.py,sha256=1FvDmK6tky7iqa5MmeZzaGbQR4pI4UPNJjNYkaDCezg,858
|
|
4
|
+
fastapi_basic/utils.py,sha256=8ympyQIXsKkxLILTI_7ug85vmKWYKqX0mpADjgHekgU,306
|
|
5
|
+
fastapi_basic-0.0.1.dist-info/METADATA,sha256=xEUoSkLjHjFzPen6wvV_EADWm09T6z1zMD_EGlI3Mrc,866
|
|
6
|
+
fastapi_basic-0.0.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
7
|
+
fastapi_basic-0.0.1.dist-info/top_level.txt,sha256=Q9PdwWxaB4dy135MQHiroRYOqArdUSaIeEkzYinN6W0,14
|
|
8
|
+
fastapi_basic-0.0.1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
fastapi_basic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
fastapi_basic/base_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
fastapi_basic/base_factory.py,sha256=Rr9ofM4c_JYmN6RVgsH8YmECjaLkcxAOrnmVQGnQ9Mg,524
|
|
4
|
-
fastapi_basic-0.0.0.dist-info/METADATA,sha256=152B6mla123zlyNh_hJ38lp7JEM5RlzxQeS7Sierrhg,704
|
|
5
|
-
fastapi_basic-0.0.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
6
|
-
fastapi_basic-0.0.0.dist-info/top_level.txt,sha256=Q9PdwWxaB4dy135MQHiroRYOqArdUSaIeEkzYinN6W0,14
|
|
7
|
-
fastapi_basic-0.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|