FastAPI-fastkit 1.0.1__py3-none-any.whl → 1.0.2__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.
Files changed (127) hide show
  1. fastapi_fastkit/__init__.py +10 -1
  2. fastapi_fastkit/backend/main.py +482 -482
  3. fastapi_fastkit/backend/transducer.py +106 -106
  4. fastapi_fastkit/cli.py +664 -631
  5. fastapi_fastkit/core/settings.py +155 -155
  6. fastapi_fastkit/fastapi_project_template/README.md +90 -90
  7. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.env-tpl +1 -1
  8. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.gitignore-tpl +30 -30
  9. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/README.md-tpl +107 -107
  10. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/requirements.txt-tpl +36 -36
  11. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/format.sh-tpl +5 -5
  12. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/lint.sh-tpl +5 -5
  13. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/run-server.sh-tpl +8 -8
  14. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/test.sh-tpl +6 -6
  15. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.cfg-tpl +14 -14
  16. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.py-tpl +25 -25
  17. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/api.py-tpl +9 -9
  18. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/routes/items.py-tpl +57 -57
  19. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/core/config.py-tpl +64 -64
  20. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/crud/items.py-tpl +21 -21
  21. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/main.py-tpl +26 -26
  22. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/mocks/mock_items.json-tpl +8 -8
  23. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/schemas/items.py-tpl +22 -22
  24. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/conftest.py-tpl +42 -42
  25. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/test_items.py-tpl +48 -48
  26. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.env-tpl +1 -1
  27. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.gitignore-tpl +191 -191
  28. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/README.md-tpl +156 -156
  29. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/requirements.txt-tpl +36 -36
  30. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/format.sh-tpl +5 -5
  31. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/lint.sh-tpl +5 -5
  32. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/run-server.sh-tpl +8 -8
  33. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/test.sh-tpl +6 -6
  34. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.cfg-tpl +12 -12
  35. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.py-tpl +27 -27
  36. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/.DS_Store +0 -0
  37. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/api.py-tpl +9 -9
  38. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/routes/items.py-tpl +172 -172
  39. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/core/config.py-tpl +64 -64
  40. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/crud/items.py-tpl +21 -21
  41. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/exceptions.py-tpl +103 -103
  42. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/pagination.py-tpl +72 -72
  43. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/main.py-tpl +39 -39
  44. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/mocks/mock_items.json-tpl +8 -8
  45. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/base.py-tpl +49 -49
  46. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/items.py-tpl +22 -22
  47. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/utils/documents.py-tpl +20 -20
  48. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/conftest.py-tpl +42 -42
  49. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/test_items.py-tpl +61 -61
  50. fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl +101 -101
  51. fastapi_fastkit/fastapi_project_template/fastapi-default/scripts/run-server.sh-tpl +8 -8
  52. fastapi_fastkit/fastapi_project_template/fastapi-default/setup.py-tpl +22 -22
  53. fastapi_fastkit/fastapi_project_template/fastapi-default/src/mocks/mock_items.json-tpl +8 -8
  54. fastapi_fastkit/fastapi_project_template/fastapi-default/tests/conftest.py-tpl +30 -30
  55. fastapi_fastkit/fastapi_project_template/fastapi-default/tests/test_items.py-tpl +44 -44
  56. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.env-tpl +1 -1
  57. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.gitignore-tpl +30 -30
  58. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/Dockerfile-tpl +23 -23
  59. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/README.md-tpl +119 -119
  60. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/requirements.txt-tpl +36 -36
  61. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/format.sh-tpl +5 -5
  62. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/lint.sh-tpl +5 -5
  63. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/run-server.sh-tpl +8 -8
  64. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/test.sh-tpl +6 -6
  65. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.cfg-tpl +13 -13
  66. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.py-tpl +22 -22
  67. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/api.py-tpl +6 -6
  68. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/routes/items.py-tpl +54 -54
  69. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/core/config.py-tpl +64 -64
  70. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/crud/items.py-tpl +15 -15
  71. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/main.py-tpl +26 -26
  72. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/mocks/mock_items.json-tpl +8 -8
  73. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/schemas/items.py-tpl +19 -19
  74. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/conftest.py-tpl +30 -30
  75. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/test_items.py-tpl +44 -44
  76. fastapi_fastkit/fastapi_project_template/fastapi-empty/.env-tpl +1 -1
  77. fastapi_fastkit/fastapi_project_template/fastapi-empty/setup.py-tpl +22 -22
  78. fastapi_fastkit/fastapi_project_template/fastapi-empty/src/core/config.py-tpl +75 -75
  79. fastapi_fastkit/fastapi_project_template/fastapi-empty/src/main.py-tpl +36 -36
  80. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.env-tpl +9 -9
  81. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.gitignore-tpl +30 -30
  82. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/Dockerfile-tpl +23 -23
  83. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/README.md-tpl +144 -144
  84. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/alembic.ini-tpl +119 -119
  85. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/docker-compose.yml-tpl +44 -44
  86. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/requirements.txt-tpl +41 -41
  87. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/format.sh-tpl +5 -5
  88. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/lint.sh-tpl +5 -5
  89. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/pre-start.sh-tpl +16 -16
  90. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/run-server.sh-tpl +8 -8
  91. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/test.sh-tpl +10 -10
  92. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.cfg-tpl +13 -13
  93. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.py-tpl +25 -25
  94. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/README-tpl +1 -1
  95. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/env.py-tpl +85 -85
  96. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/script.py.mako-tpl +26 -26
  97. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/versions/bedcdc35b64a_first_alembic.py-tpl +37 -37
  98. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/api.py-tpl +11 -11
  99. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/deps.py-tpl +19 -19
  100. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/routes/items.py-tpl +109 -109
  101. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/config.py-tpl +88 -88
  102. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/db.py-tpl +53 -53
  103. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/crud/items.py-tpl +102 -102
  104. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/main.py-tpl +45 -45
  105. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/schemas/items.py-tpl +54 -54
  106. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/backend_pre_start.py-tpl +39 -39
  107. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/init_data.py-tpl +23 -23
  108. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/tests_pre_start.py-tpl +39 -39
  109. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/conftest.py-tpl +63 -63
  110. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/test_items.py-tpl +44 -44
  111. fastapi_fastkit/fastapi_project_template/modules/api/routes/new_route.py-tpl +64 -64
  112. fastapi_fastkit/fastapi_project_template/modules/crud/new_route.py-tpl +29 -29
  113. fastapi_fastkit/fastapi_project_template/modules/schemas/new_route.py-tpl +23 -23
  114. fastapi_fastkit/logs/fastkit_debug_20250702_161423.log +21 -0
  115. fastapi_fastkit/logs/fastkit_debug_20250702_162706.log +20 -0
  116. fastapi_fastkit/logs/fastkit_debug_20250702_163010.log +21 -0
  117. fastapi_fastkit/logs/fastkit_debug_20250702_163526.log +21 -0
  118. fastapi_fastkit/logs/fastkit_debug_20250702_164053.log +21 -0
  119. fastapi_fastkit/logs/fastkit_debug_20250702_165220.log +21 -0
  120. fastapi_fastkit/logs/fastkit_debug_20250702_165647.log +21 -0
  121. fastapi_fastkit/utils/logging.py +112 -1
  122. fastapi_fastkit/utils/main.py +140 -129
  123. {fastapi_fastkit-1.0.1.dist-info → fastapi_fastkit-1.0.2.dist-info}/METADATA +13 -2
  124. {fastapi_fastkit-1.0.1.dist-info → fastapi_fastkit-1.0.2.dist-info}/RECORD +127 -119
  125. {fastapi_fastkit-1.0.1.dist-info → fastapi_fastkit-1.0.2.dist-info}/licenses/LICENSE +21 -21
  126. {fastapi_fastkit-1.0.1.dist-info → fastapi_fastkit-1.0.2.dist-info}/WHEEL +0 -0
  127. {fastapi_fastkit-1.0.1.dist-info → fastapi_fastkit-1.0.2.dist-info}/entry_points.txt +0 -0
@@ -1,155 +1,155 @@
1
- # --------------------------------------------------------------------------
2
- # The Module defines fastapi-fastkit project's general Env settings.
3
- #
4
- # @author bnbong bbbong9@gmail.com
5
- # --------------------------------------------------------------------------
6
- import os
7
- from pathlib import Path
8
-
9
- from .exceptions import BackendExceptions
10
-
11
-
12
- class FastkitConfig:
13
- # Overridable values
14
- FASTKIT_PROJECT_ROOT: str = "" # default : None (will be overridden)
15
- FASTKIT_TEMPLATE_ROOT: str = "" # default : None (will be overridden)
16
- LOG_FILE_PATH: str = "" # default : None (will be overridden)
17
- USER_WORKSPACE: str = "" # default : None (will be overridden)
18
-
19
- # Default Options
20
- DEBUG_MODE: bool = False
21
- LOGGING_LEVEL: str = "DEBUG"
22
-
23
- # Template Metadata Options
24
- TEMPLATE_PATHS: dict[str, list[str] | dict[str, list[str]]] = {
25
- "main": [
26
- "src/main.py",
27
- "main.py",
28
- ],
29
- "setup": [
30
- "setup.py",
31
- "src/setup.py",
32
- ],
33
- "config": {
34
- "files": ["settings.py", "config.py"],
35
- "paths": [
36
- "src/core",
37
- "src",
38
- "",
39
- ],
40
- },
41
- }
42
-
43
- # Startproject Options
44
- PROJECT_STACKS: dict[str, list[str]] = {
45
- "minimal": ["fastapi", "uvicorn", "pydantic", "pydantic-settings"],
46
- "standard": [
47
- "fastapi",
48
- "uvicorn",
49
- "sqlalchemy",
50
- "alembic",
51
- "pytest",
52
- "pydantic",
53
- "pydantic-settings",
54
- ],
55
- "full": [
56
- "fastapi",
57
- "uvicorn",
58
- "sqlalchemy",
59
- "alembic",
60
- "pytest",
61
- "redis",
62
- "celery",
63
- "pydantic",
64
- "pydantic-settings",
65
- ],
66
- }
67
-
68
- # Testing Options
69
- TEST_SERVER_PORT: int = 8000
70
- TEST_DEFAULT_TERMINAL_WIDTH: int = 80
71
- TEST_MAX_TERMINAL_WIDTH: int = 1000
72
-
73
- def set_debug_mode(self, debug_mode: bool = True) -> None:
74
- self.DEBUG_MODE = debug_mode
75
-
76
- @staticmethod
77
- def __get_fastapi_fastkit_root() -> Path:
78
- """
79
- Returns the root directory of the installed FastAPI-fastkit package.
80
- For development: returns the project root
81
- For installed package: returns the package installation directory
82
- """
83
- try:
84
- import fastapi_fastkit
85
-
86
- package_root = Path(fastapi_fastkit.__file__).parent.parent
87
- if package_root.name == "site-packages":
88
- return package_root / "fastapi_fastkit"
89
- return package_root
90
- except ImportError:
91
- # Fallback for development environment
92
- return Path(__file__).parent.parent.parent.parent
93
-
94
- @staticmethod
95
- def __get_template_root() -> Path:
96
- """
97
- Returns the template directory of the installed FastAPI-fastkit package.
98
- For development: returns the project template directory
99
- For installed package: returns the package template directory
100
- """
101
- try:
102
- import fastapi_fastkit
103
-
104
- package_root = Path(fastapi_fastkit.__file__).parent
105
- template_dir = package_root / "fastapi_project_template"
106
- if template_dir.exists():
107
- return template_dir
108
- # If inside site-packages
109
- if package_root.parent.name == "site-packages":
110
- return (
111
- package_root.parent / "fastapi_fastkit" / "fastapi_project_template"
112
- )
113
- return package_root.parent / "fastapi_project_template"
114
- except ImportError:
115
- # Fallback for development environment
116
- return Path(__file__).parent.parent / "fastapi_project_template"
117
-
118
- @classmethod
119
- def __init__(cls) -> None:
120
- """
121
- Initialize the configuration by performing important checks and setups.
122
- Override directories to correct position.
123
- """
124
- cls.FASTKIT_PROJECT_ROOT = str(cls.__get_fastapi_fastkit_root())
125
- cls.FASTKIT_TEMPLATE_ROOT = str(cls.__get_template_root())
126
- cls.LOG_FILE_PATH = os.path.join(
127
- cls.FASTKIT_PROJECT_ROOT, "logs", "fastkit.log"
128
- )
129
- cls.USER_WORKSPACE = os.getcwd()
130
-
131
- # Validate the configurations
132
- cls._validate()
133
-
134
- @classmethod
135
- def _validate(cls) -> None:
136
- """
137
- Validate the configuration settings to ensure that they are correct.
138
- Raises an error if validation fails.
139
- """
140
- if not cls.FASTKIT_PROJECT_ROOT or not os.path.isdir(cls.FASTKIT_PROJECT_ROOT):
141
- raise BackendExceptions(
142
- "FASTKIT_PROJECT_ROOT is not allocated to valid directory."
143
- )
144
-
145
- if not cls.FASTKIT_TEMPLATE_ROOT or not os.path.isdir(cls.FASTKIT_PROJECT_ROOT):
146
- raise BackendExceptions(
147
- "FASTKIT_TEMPLATE_ROOT is not allocated to valid directory."
148
- )
149
-
150
- log_dir = os.path.dirname(cls.LOG_FILE_PATH)
151
- if not os.path.exists(log_dir):
152
- os.makedirs(log_dir)
153
-
154
-
155
- settings = FastkitConfig()
1
+ # --------------------------------------------------------------------------
2
+ # The Module defines fastapi-fastkit project's general Env settings.
3
+ #
4
+ # @author bnbong bbbong9@gmail.com
5
+ # --------------------------------------------------------------------------
6
+ import os
7
+ from pathlib import Path
8
+
9
+ from .exceptions import BackendExceptions
10
+
11
+
12
+ class FastkitConfig:
13
+ # Overridable values
14
+ FASTKIT_PROJECT_ROOT: str = "" # default : None (will be overridden)
15
+ FASTKIT_TEMPLATE_ROOT: str = "" # default : None (will be overridden)
16
+ LOG_FILE_PATH: str = "" # default : None (will be overridden)
17
+ USER_WORKSPACE: str = "" # default : None (will be overridden)
18
+
19
+ # Default Options
20
+ DEBUG_MODE: bool = False
21
+ LOGGING_LEVEL: str = "DEBUG"
22
+
23
+ # Template Metadata Options
24
+ TEMPLATE_PATHS: dict[str, list[str] | dict[str, list[str]]] = {
25
+ "main": [
26
+ "src/main.py",
27
+ "main.py",
28
+ ],
29
+ "setup": [
30
+ "setup.py",
31
+ "src/setup.py",
32
+ ],
33
+ "config": {
34
+ "files": ["settings.py", "config.py"],
35
+ "paths": [
36
+ "src/core",
37
+ "src",
38
+ "",
39
+ ],
40
+ },
41
+ }
42
+
43
+ # Startproject Options
44
+ PROJECT_STACKS: dict[str, list[str]] = {
45
+ "minimal": ["fastapi", "uvicorn", "pydantic", "pydantic-settings"],
46
+ "standard": [
47
+ "fastapi",
48
+ "uvicorn",
49
+ "sqlalchemy",
50
+ "alembic",
51
+ "pytest",
52
+ "pydantic",
53
+ "pydantic-settings",
54
+ ],
55
+ "full": [
56
+ "fastapi",
57
+ "uvicorn",
58
+ "sqlalchemy",
59
+ "alembic",
60
+ "pytest",
61
+ "redis",
62
+ "celery",
63
+ "pydantic",
64
+ "pydantic-settings",
65
+ ],
66
+ }
67
+
68
+ # Testing Options
69
+ TEST_SERVER_PORT: int = 8000
70
+ TEST_DEFAULT_TERMINAL_WIDTH: int = 80
71
+ TEST_MAX_TERMINAL_WIDTH: int = 1000
72
+
73
+ def set_debug_mode(self, debug_mode: bool = True) -> None:
74
+ self.DEBUG_MODE = debug_mode
75
+
76
+ @staticmethod
77
+ def __get_fastapi_fastkit_root() -> Path:
78
+ """
79
+ Returns the root directory of the installed FastAPI-fastkit package.
80
+ For development: returns the project root
81
+ For installed package: returns the package installation directory
82
+ """
83
+ try:
84
+ import fastapi_fastkit
85
+
86
+ package_root = Path(fastapi_fastkit.__file__).parent.parent
87
+ if package_root.name == "site-packages":
88
+ return package_root / "fastapi_fastkit"
89
+ return package_root
90
+ except ImportError:
91
+ # Fallback for development environment
92
+ return Path(__file__).parent.parent.parent.parent
93
+
94
+ @staticmethod
95
+ def __get_template_root() -> Path:
96
+ """
97
+ Returns the template directory of the installed FastAPI-fastkit package.
98
+ For development: returns the project template directory
99
+ For installed package: returns the package template directory
100
+ """
101
+ try:
102
+ import fastapi_fastkit
103
+
104
+ package_root = Path(fastapi_fastkit.__file__).parent
105
+ template_dir = package_root / "fastapi_project_template"
106
+ if template_dir.exists():
107
+ return template_dir
108
+ # If inside site-packages
109
+ if package_root.parent.name == "site-packages":
110
+ return (
111
+ package_root.parent / "fastapi_fastkit" / "fastapi_project_template"
112
+ )
113
+ return package_root.parent / "fastapi_project_template"
114
+ except ImportError:
115
+ # Fallback for development environment
116
+ return Path(__file__).parent.parent / "fastapi_project_template"
117
+
118
+ @classmethod
119
+ def __init__(cls) -> None:
120
+ """
121
+ Initialize the configuration by performing important checks and setups.
122
+ Override directories to correct position.
123
+ """
124
+ cls.FASTKIT_PROJECT_ROOT = str(cls.__get_fastapi_fastkit_root())
125
+ cls.FASTKIT_TEMPLATE_ROOT = str(cls.__get_template_root())
126
+ cls.LOG_FILE_PATH = os.path.join(
127
+ cls.FASTKIT_PROJECT_ROOT, "logs", "fastkit.log"
128
+ )
129
+ cls.USER_WORKSPACE = os.getcwd()
130
+
131
+ # Validate the configurations
132
+ cls._validate()
133
+
134
+ @classmethod
135
+ def _validate(cls) -> None:
136
+ """
137
+ Validate the configuration settings to ensure that they are correct.
138
+ Raises an error if validation fails.
139
+ """
140
+ if not cls.FASTKIT_PROJECT_ROOT or not os.path.isdir(cls.FASTKIT_PROJECT_ROOT):
141
+ raise BackendExceptions(
142
+ "FASTKIT_PROJECT_ROOT is not allocated to valid directory."
143
+ )
144
+
145
+ if not cls.FASTKIT_TEMPLATE_ROOT or not os.path.isdir(cls.FASTKIT_PROJECT_ROOT):
146
+ raise BackendExceptions(
147
+ "FASTKIT_TEMPLATE_ROOT is not allocated to valid directory."
148
+ )
149
+
150
+ log_dir = os.path.dirname(cls.LOG_FILE_PATH)
151
+ if not os.path.exists(log_dir):
152
+ os.makedirs(log_dir)
153
+
154
+
155
+ settings = FastkitConfig()
@@ -1,90 +1,90 @@
1
- # About fastapi project templates
2
-
3
- Each fastapi demo project in this folder is pasted to the user's local folder with the FastAPI-fastkit replication as the source code is.
4
-
5
- For those with experience in developing Django, it is easy to understand that it performs a similar operation to the `$ django-admin startproject <project-name>` cli-operation.
6
-
7
- All source codes in demo projects must consist of **`.py-tpl`**, _not_ .py.
8
-
9
- ## Base structure of FastAPI template project
10
-
11
- ### Required Structure
12
-
13
- ```
14
- template-name/
15
- ├── src/
16
- │ ├── main.py-tpl
17
- │ ├── config/
18
- │ ├── models/
19
- │ ├── routes/
20
- │ └── utils/
21
- ├── tests/
22
- ├── scripts/
23
- ├── requirements.txt-tpl
24
- ├── setup.py-tpl
25
- └── README.md-tpl
26
- ```
27
-
28
- ### Key Requirements:
29
-
30
- 1. All source files must use `.py-tpl` extension
31
- 2. `setup.py` must include `fastapi-fastkit` string in project description
32
- for example:
33
- ```
34
- ...
35
- setup(
36
- ...
37
- description = "[fastapi-fastkit templated] <description>",
38
- ...
39
- )
40
- ```
41
- 3. `setup.py` must include `install_requires` section, it must include essential dependencies for the template project. Also, note that install_requires list must be type annotated.
42
- for example:
43
- ```
44
- ...
45
- install_requires: list[str] = [
46
- ...
47
- ],
48
- ```
49
- 4. Basic CRUD operations example
50
- 5. Unit tests implementation
51
- 6. API documentation (OpenAPI/Swagger)
52
-
53
- ## Base structure of modules template
54
-
55
- This template is used to create a new FastAPI project with a specific module structure.
56
-
57
- This template strategy is used at `fastkit addroute` operation.
58
-
59
- The module structure is as follows (version 1.0.X based):
60
-
61
- ```
62
- modules/
63
- ├── api/
64
- ├── crud/
65
- └── schemas/
66
- ```
67
-
68
- In further versions, I don't have any plan to add other modules to this template, for example, `auth`, `db`, etc.
69
-
70
- So, if you have any suggestions, please let me know or contribute to this operation.
71
-
72
-
73
- ## Adding new FastAPI-based template project
74
-
75
- Before adding new FastAPI-based template project here, I strongly recommend that you read the
76
- [SECURITY.md](../SECURITY.md) and [CODE_OF_CONDUCT.md](../CODE_OF_CONDUCT.md) files to understand
77
- the direction of this project and the precautions for cooperation.
78
-
79
- Follow these steps when adding a new template:
80
-
81
- 1. Follow template structure
82
- 2. Pass inspector.py tests
83
- 3. Meet security requirements
84
- 4. Pre-PR checklist:
85
- - [ ] All files use .py-tpl extension
86
- - [ ] FastAPI-fastkit dependency included
87
- - [ ] Security requirements met
88
- - [ ] Tests implemented and passing
89
- - [ ] Documentation complete
90
- - [ ] inspector.py validation passes
1
+ # About fastapi project templates
2
+
3
+ Each fastapi demo project in this folder is pasted to the user's local folder with the FastAPI-fastkit replication as the source code is.
4
+
5
+ For those with experience in developing Django, it is easy to understand that it performs a similar operation to the `$ django-admin startproject <project-name>` cli-operation.
6
+
7
+ All source codes in demo projects must consist of **`.py-tpl`**, _not_ .py.
8
+
9
+ ## Base structure of FastAPI template project
10
+
11
+ ### Required Structure
12
+
13
+ ```
14
+ template-name/
15
+ ├── src/
16
+ │ ├── main.py-tpl
17
+ │ ├── config/
18
+ │ ├── models/
19
+ │ ├── routes/
20
+ │ └── utils/
21
+ ├── tests/
22
+ ├── scripts/
23
+ ├── requirements.txt-tpl
24
+ ├── setup.py-tpl
25
+ └── README.md-tpl
26
+ ```
27
+
28
+ ### Key Requirements:
29
+
30
+ 1. All source files must use `.py-tpl` extension
31
+ 2. `setup.py` must include `fastapi-fastkit` string in project description
32
+ for example:
33
+ ```
34
+ ...
35
+ setup(
36
+ ...
37
+ description = "[fastapi-fastkit templated] <description>",
38
+ ...
39
+ )
40
+ ```
41
+ 3. `setup.py` must include `install_requires` section, it must include essential dependencies for the template project. Also, note that install_requires list must be type annotated.
42
+ for example:
43
+ ```
44
+ ...
45
+ install_requires: list[str] = [
46
+ ...
47
+ ],
48
+ ```
49
+ 4. Basic CRUD operations example
50
+ 5. Unit tests implementation
51
+ 6. API documentation (OpenAPI/Swagger)
52
+
53
+ ## Base structure of modules template
54
+
55
+ This template is used to create a new FastAPI project with a specific module structure.
56
+
57
+ This template strategy is used at `fastkit addroute` operation.
58
+
59
+ The module structure is as follows (version 1.0.X based):
60
+
61
+ ```
62
+ modules/
63
+ ├── api/
64
+ ├── crud/
65
+ └── schemas/
66
+ ```
67
+
68
+ In further versions, I don't have any plan to add other modules to this template, for example, `auth`, `db`, etc.
69
+
70
+ So, if you have any suggestions, please let me know or contribute to this operation.
71
+
72
+
73
+ ## Adding new FastAPI-based template project
74
+
75
+ Before adding new FastAPI-based template project here, I strongly recommend that you read the
76
+ [SECURITY.md](../SECURITY.md) and [CODE_OF_CONDUCT.md](../CODE_OF_CONDUCT.md) files to understand
77
+ the direction of this project and the precautions for cooperation.
78
+
79
+ Follow these steps when adding a new template:
80
+
81
+ 1. Follow template structure
82
+ 2. Pass inspector.py tests
83
+ 3. Meet security requirements
84
+ 4. Pre-PR checklist:
85
+ - [ ] All files use .py-tpl extension
86
+ - [ ] FastAPI-fastkit dependency included
87
+ - [ ] Security requirements met
88
+ - [ ] Tests implemented and passing
89
+ - [ ] Documentation complete
90
+ - [ ] inspector.py validation passes
@@ -1 +1 @@
1
- SECRET_KEY=changethis
1
+ SECRET_KEY=changethis
@@ -1,30 +1,30 @@
1
- .idea
2
- .ipynb_checkpoints
3
- .mypy_cache
4
- .vscode
5
- __pycache__
6
- .pytest_cache
7
- htmlcov
8
- dist
9
- site
10
- .coverage*
11
- coverage.xml
12
- .netlify
13
- test.db
14
- log.txt
15
- Pipfile.lock
16
- env3.*
17
- env
18
- docs_build
19
- site_build
20
- venv
21
- docs.zip
22
- archive.zip
23
-
24
- # vim temporary files
25
- *~
26
- .*.sw?
27
- .cache
28
-
29
- # macOS
30
- .DS_Store
1
+ .idea
2
+ .ipynb_checkpoints
3
+ .mypy_cache
4
+ .vscode
5
+ __pycache__
6
+ .pytest_cache
7
+ htmlcov
8
+ dist
9
+ site
10
+ .coverage*
11
+ coverage.xml
12
+ .netlify
13
+ test.db
14
+ log.txt
15
+ Pipfile.lock
16
+ env3.*
17
+ env
18
+ docs_build
19
+ site_build
20
+ venv
21
+ docs.zip
22
+ archive.zip
23
+
24
+ # vim temporary files
25
+ *~
26
+ .*.sw?
27
+ .cache
28
+
29
+ # macOS
30
+ .DS_Store