FastAPI-fastkit 1.0.0__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.
- fastapi_fastkit/__init__.py +10 -1
- fastapi_fastkit/backend/main.py +482 -482
- fastapi_fastkit/backend/transducer.py +106 -106
- fastapi_fastkit/cli.py +664 -631
- fastapi_fastkit/core/settings.py +155 -155
- fastapi_fastkit/fastapi_project_template/README.md +90 -90
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.env-tpl +1 -1
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.gitignore-tpl +30 -30
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/README.md-tpl +107 -107
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/requirements.txt-tpl +36 -36
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/format.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/lint.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/run-server.sh-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/test.sh-tpl +6 -6
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.cfg-tpl +14 -14
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.py-tpl +25 -25
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/api.py-tpl +9 -9
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/routes/items.py-tpl +57 -57
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/core/config.py-tpl +64 -64
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/crud/items.py-tpl +21 -21
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/main.py-tpl +26 -26
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/mocks/mock_items.json-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/schemas/items.py-tpl +22 -22
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/conftest.py-tpl +42 -42
- fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/test_items.py-tpl +48 -48
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.env-tpl +1 -1
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.gitignore-tpl +191 -191
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/README.md-tpl +156 -156
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/requirements.txt-tpl +36 -36
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/format.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/lint.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/run-server.sh-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/test.sh-tpl +6 -6
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.cfg-tpl +12 -12
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.py-tpl +27 -27
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/.DS_Store +0 -0
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/api.py-tpl +9 -9
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/routes/items.py-tpl +172 -172
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/core/config.py-tpl +64 -64
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/crud/items.py-tpl +21 -21
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/exceptions.py-tpl +103 -103
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/pagination.py-tpl +72 -72
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/main.py-tpl +39 -39
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/mocks/mock_items.json-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/base.py-tpl +49 -49
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/items.py-tpl +22 -22
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/utils/documents.py-tpl +20 -20
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/conftest.py-tpl +42 -42
- fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/test_items.py-tpl +61 -61
- fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl +101 -101
- fastapi_fastkit/fastapi_project_template/fastapi-default/scripts/run-server.sh-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-default/setup.py-tpl +22 -22
- fastapi_fastkit/fastapi_project_template/fastapi-default/src/mocks/mock_items.json-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-default/tests/conftest.py-tpl +30 -30
- fastapi_fastkit/fastapi_project_template/fastapi-default/tests/test_items.py-tpl +44 -44
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.env-tpl +1 -1
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.gitignore-tpl +30 -30
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/Dockerfile-tpl +23 -23
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/README.md-tpl +119 -119
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/requirements.txt-tpl +36 -36
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/format.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/lint.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/run-server.sh-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/test.sh-tpl +6 -6
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.cfg-tpl +13 -13
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.py-tpl +22 -22
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/api.py-tpl +6 -6
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/routes/items.py-tpl +54 -54
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/core/config.py-tpl +64 -64
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/crud/items.py-tpl +15 -15
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/main.py-tpl +26 -26
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/mocks/mock_items.json-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/schemas/items.py-tpl +19 -19
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/conftest.py-tpl +30 -30
- fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/test_items.py-tpl +44 -44
- fastapi_fastkit/fastapi_project_template/fastapi-empty/.env-tpl +1 -1
- fastapi_fastkit/fastapi_project_template/fastapi-empty/setup.py-tpl +22 -22
- fastapi_fastkit/fastapi_project_template/fastapi-empty/src/core/config.py-tpl +75 -75
- fastapi_fastkit/fastapi_project_template/fastapi-empty/src/main.py-tpl +36 -36
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.env-tpl +9 -9
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.gitignore-tpl +30 -30
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/Dockerfile-tpl +23 -23
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/README.md-tpl +144 -144
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/alembic.ini-tpl +119 -119
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/docker-compose.yml-tpl +44 -44
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/requirements.txt-tpl +41 -41
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/format.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/lint.sh-tpl +5 -5
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/pre-start.sh-tpl +16 -16
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/run-server.sh-tpl +8 -8
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/test.sh-tpl +10 -10
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.cfg-tpl +13 -13
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.py-tpl +25 -25
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/README-tpl +1 -1
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/env.py-tpl +85 -85
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/script.py.mako-tpl +26 -26
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/versions/bedcdc35b64a_first_alembic.py-tpl +37 -37
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/api.py-tpl +11 -11
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/deps.py-tpl +19 -19
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/routes/items.py-tpl +109 -109
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/config.py-tpl +88 -88
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/db.py-tpl +53 -53
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/crud/items.py-tpl +102 -102
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/main.py-tpl +45 -45
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/schemas/items.py-tpl +54 -54
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/backend_pre_start.py-tpl +39 -39
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/init_data.py-tpl +23 -23
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/tests_pre_start.py-tpl +39 -39
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/conftest.py-tpl +63 -63
- fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/test_items.py-tpl +44 -44
- fastapi_fastkit/fastapi_project_template/modules/api/routes/new_route.py-tpl +64 -64
- fastapi_fastkit/fastapi_project_template/modules/crud/new_route.py-tpl +29 -29
- fastapi_fastkit/fastapi_project_template/modules/schemas/new_route.py-tpl +23 -23
- fastapi_fastkit/logs/fastkit_debug_20250702_161423.log +21 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_162706.log +20 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_163010.log +21 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_163526.log +21 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_164053.log +21 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_165220.log +21 -0
- fastapi_fastkit/logs/fastkit_debug_20250702_165647.log +21 -0
- fastapi_fastkit/utils/logging.py +112 -1
- fastapi_fastkit/utils/main.py +140 -129
- fastapi_fastkit-1.0.2.dist-info/METADATA +320 -0
- {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/RECORD +127 -119
- {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/WHEEL +1 -1
- {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/licenses/LICENSE +21 -21
- fastapi_fastkit-1.0.0.dist-info/METADATA +0 -208
- {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/entry_points.txt +0 -0
fastapi_fastkit/utils/main.py
CHANGED
|
@@ -1,129 +1,140 @@
|
|
|
1
|
-
# --------------------------------------------------------------------------
|
|
2
|
-
# The Module defines utility functions for FastAPI-fastkit CLI.
|
|
3
|
-
#
|
|
4
|
-
# @author bnbong bbbong9@gmail.com
|
|
5
|
-
# --------------------------------------------------------------------------
|
|
6
|
-
import os
|
|
7
|
-
import re
|
|
8
|
-
import traceback
|
|
9
|
-
from typing import Any, Optional
|
|
10
|
-
|
|
11
|
-
import click
|
|
12
|
-
from click.core import Context
|
|
13
|
-
from rich.console import Console
|
|
14
|
-
from rich.panel import Panel
|
|
15
|
-
from rich.table import Table
|
|
16
|
-
from rich.text import Text
|
|
17
|
-
|
|
18
|
-
from fastapi_fastkit import console
|
|
19
|
-
from fastapi_fastkit.core.settings import settings
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
error_text
|
|
33
|
-
error_text.append(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"""
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
""
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
# The Module defines utility functions for FastAPI-fastkit CLI.
|
|
3
|
+
#
|
|
4
|
+
# @author bnbong bbbong9@gmail.com
|
|
5
|
+
# --------------------------------------------------------------------------
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
8
|
+
import traceback
|
|
9
|
+
from typing import Any, Optional
|
|
10
|
+
|
|
11
|
+
import click
|
|
12
|
+
from click.core import Context
|
|
13
|
+
from rich.console import Console
|
|
14
|
+
from rich.panel import Panel
|
|
15
|
+
from rich.table import Table
|
|
16
|
+
from rich.text import Text
|
|
17
|
+
|
|
18
|
+
from fastapi_fastkit import console
|
|
19
|
+
from fastapi_fastkit.core.settings import settings
|
|
20
|
+
from fastapi_fastkit.utils.logging import get_logger
|
|
21
|
+
|
|
22
|
+
REGEX = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def print_error(
|
|
26
|
+
message: str,
|
|
27
|
+
title: str = "Error",
|
|
28
|
+
console: Console = console,
|
|
29
|
+
show_traceback: bool = False,
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Print an error message with specified output style."""
|
|
32
|
+
error_text = Text()
|
|
33
|
+
error_text.append("❌ ", style="bold red")
|
|
34
|
+
error_text.append(message)
|
|
35
|
+
console.print(Panel(error_text, border_style="red", title=title))
|
|
36
|
+
|
|
37
|
+
# Log error if debug mode is enabled
|
|
38
|
+
if settings.DEBUG_MODE:
|
|
39
|
+
logger = get_logger()
|
|
40
|
+
logger.error(f"Error: {message}")
|
|
41
|
+
|
|
42
|
+
if show_traceback and settings.DEBUG_MODE:
|
|
43
|
+
console.print("[bold yellow]Stack trace:[/bold yellow]")
|
|
44
|
+
console.print(traceback.format_exc())
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def handle_exception(e: Exception, message: Optional[str] = None) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Handle exception and print appropriate error message.
|
|
50
|
+
|
|
51
|
+
:param e: The exception that occurred
|
|
52
|
+
:param message: Optional custom error message
|
|
53
|
+
"""
|
|
54
|
+
error_msg = message or f"Error: {str(e)}"
|
|
55
|
+
|
|
56
|
+
# Log exception if debug mode is enabled
|
|
57
|
+
if settings.DEBUG_MODE:
|
|
58
|
+
logger = get_logger()
|
|
59
|
+
logger.exception(f"Exception occurred: {error_msg}", exc_info=e)
|
|
60
|
+
|
|
61
|
+
# Show traceback if in debug mode
|
|
62
|
+
print_error(error_msg, show_traceback=True)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def print_success(
|
|
66
|
+
message: str, title: str = "Success", console: Console = console
|
|
67
|
+
) -> None:
|
|
68
|
+
"""Print a success message with specified output style."""
|
|
69
|
+
success_text = Text()
|
|
70
|
+
success_text.append("✨ ", style="bold yellow")
|
|
71
|
+
success_text.append(message, style="bold green")
|
|
72
|
+
console.print(Panel(success_text, border_style="green", title=title))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def print_warning(
|
|
76
|
+
message: str, title: str = "Warning", console: Console = console
|
|
77
|
+
) -> None:
|
|
78
|
+
"""Print a warning message with specified output style."""
|
|
79
|
+
warning_text = Text()
|
|
80
|
+
warning_text.append("⚠️ ", style="bold yellow")
|
|
81
|
+
warning_text.append(message)
|
|
82
|
+
console.print(Panel(warning_text, border_style="yellow", title=title))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def print_info(message: str, title: str = "Info", console: Console = console) -> None:
|
|
86
|
+
"""Print an info message with specified output style."""
|
|
87
|
+
info_text = Text()
|
|
88
|
+
info_text.append("ℹ ", style="bold blue")
|
|
89
|
+
info_text.append(message)
|
|
90
|
+
console.print(Panel(info_text, border_style="blue", title=title))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def create_info_table(
|
|
94
|
+
title: str,
|
|
95
|
+
data: Optional[dict[str, str]] = None,
|
|
96
|
+
show_header: bool = False,
|
|
97
|
+
console: Console = console,
|
|
98
|
+
) -> Table:
|
|
99
|
+
"""Create a table for displaying information."""
|
|
100
|
+
table = Table(title=title, show_header=show_header, title_style="bold magenta")
|
|
101
|
+
table.add_column("Field", style="cyan")
|
|
102
|
+
table.add_column("Value", style="green")
|
|
103
|
+
|
|
104
|
+
if data:
|
|
105
|
+
for key, value in data.items():
|
|
106
|
+
table.add_row(key, value)
|
|
107
|
+
|
|
108
|
+
return table
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def validate_email(ctx: Context, param: Any, value: Any) -> Any:
|
|
112
|
+
"""Validate email format."""
|
|
113
|
+
try:
|
|
114
|
+
if not re.match(REGEX, value):
|
|
115
|
+
raise ValueError(value)
|
|
116
|
+
return value
|
|
117
|
+
except ValueError as e:
|
|
118
|
+
print_error(f"Incorrect email address given: {e}")
|
|
119
|
+
value = click.prompt(param.prompt)
|
|
120
|
+
return validate_email(ctx, param, value)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def is_fastkit_project(project_dir: str) -> bool:
|
|
124
|
+
"""
|
|
125
|
+
Check if the project was created with fastkit.
|
|
126
|
+
Inspects the contents of the setup.py file.
|
|
127
|
+
|
|
128
|
+
:param project_dir: Project directory
|
|
129
|
+
:return: True if the project was created with fastkit, False otherwise
|
|
130
|
+
"""
|
|
131
|
+
setup_py = os.path.join(project_dir, "setup.py")
|
|
132
|
+
if not os.path.exists(setup_py):
|
|
133
|
+
return False
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
with open(setup_py, "r") as f:
|
|
137
|
+
content = f.read()
|
|
138
|
+
return "FastAPI-fastkit" in content
|
|
139
|
+
except:
|
|
140
|
+
return False
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: FastAPI-fastkit
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Fast, easy-to-use starter kit for new users of Python and FastAPI
|
|
5
|
+
Author-Email: bnbong <bbbong9@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bnbong/FastAPI-kit
|
|
8
|
+
Project-URL: Repository, https://github.com/bnbong/FastAPI-kit
|
|
9
|
+
Project-URL: Documentation, https://bnbong.github.io/FastAPI-fastkit/
|
|
10
|
+
Project-URL: Changelog, https://bnbong.github.io/FastAPI-fastkit/changelog/
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Requires-Dist: click>=8.1.7
|
|
13
|
+
Requires-Dist: rich>=13.9.2
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8.3.3; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov>=6.2.1; extra == "dev"
|
|
17
|
+
Requires-Dist: black>=24.10.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pre-commit>=4.0.1; extra == "dev"
|
|
19
|
+
Requires-Dist: mypy>=1.12.0; extra == "dev"
|
|
20
|
+
Requires-Dist: isort>=5.13.2; extra == "dev"
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<img align="top" width="70%" src="https://bnbong.github.io/projects/img/fastkit_general_logo.png" alt="FastAPI-fastkit"/>
|
|
25
|
+
</p>
|
|
26
|
+
<p align="center">
|
|
27
|
+
<em><b>FastAPI-fastkit</b>: Fast, easy-to-use starter kit for new users of Python and FastAPI</em>
|
|
28
|
+
</p>
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="https://pypi.org/project/fastapi-fastkit" target="_blank">
|
|
31
|
+
<img src="https://img.shields.io/pypi/v/fastapi-fastkit" alt="PyPI - Version">
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://github.com/bnbong/FastAPI-fastkit/releases" target="_blank">
|
|
34
|
+
<img src="https://img.shields.io/github/v/release/bnbong/FastAPI-fastkit" alt="GitHub Release">
|
|
35
|
+
</a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
This project was created to speed up the configuration of the development environment needed to develop Python-based web apps for new users of Python and [FastAPI](https://github.com/fastapi/fastapi).
|
|
41
|
+
|
|
42
|
+
This project was inspired by the `SpringBoot initializer` & Python Django's `django-admin` cli operation.
|
|
43
|
+
|
|
44
|
+
## Key Features
|
|
45
|
+
|
|
46
|
+
- **Immediate FastAPI project creation** : Super-fast FastAPI workspace & project creation via CLI, inspired by `django-admin`feature of [Python Django](https://github.com/django/django)
|
|
47
|
+
- **Prettier CLI outputs** : beautiful CLI experiment ([rich library](https://github.com/Textualize/rich) feature)
|
|
48
|
+
- **Standards-based FastAPI project template** : All FastAPI-fastkit templates are based on Python standards and FastAPI's common use
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Install `FastAPI-fastkit` at your Python environment.
|
|
53
|
+
|
|
54
|
+
```console
|
|
55
|
+
$ pip install FastAPI-fastkit
|
|
56
|
+
---> 100%
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### Create a new FastAPI project workspace environment immediately
|
|
63
|
+
|
|
64
|
+
You can now start new FastAPI project really fast with FastAPI-fastkit!
|
|
65
|
+
|
|
66
|
+
Create a new FastAPI project workspace immediately with:
|
|
67
|
+
|
|
68
|
+
```console
|
|
69
|
+
$ fastkit init
|
|
70
|
+
Enter the project name: my-awesome-project
|
|
71
|
+
Enter the author name: John Doe
|
|
72
|
+
Enter the author email: john@example.com
|
|
73
|
+
Enter the project description: My awesome FastAPI project
|
|
74
|
+
|
|
75
|
+
Project Information
|
|
76
|
+
┌──────────────┬────────────────────────────┐
|
|
77
|
+
│ Project Name │ my-awesome-project │
|
|
78
|
+
│ Author │ John Doe │
|
|
79
|
+
│ Author Email │ john@example.com │
|
|
80
|
+
│ Description │ My awesome FastAPI project │
|
|
81
|
+
└──────────────┴────────────────────────────┘
|
|
82
|
+
|
|
83
|
+
Available Stacks and Dependencies:
|
|
84
|
+
MINIMAL Stack
|
|
85
|
+
┌──────────────┬───────────────────┐
|
|
86
|
+
│ Dependency 1 │ fastapi │
|
|
87
|
+
│ Dependency 2 │ uvicorn │
|
|
88
|
+
│ Dependency 3 │ pydantic │
|
|
89
|
+
│ Dependency 4 │ pydantic-settings │
|
|
90
|
+
└──────────────┴───────────────────┘
|
|
91
|
+
|
|
92
|
+
STANDARD Stack
|
|
93
|
+
┌──────────────┬───────────────────┐
|
|
94
|
+
│ Dependency 1 │ fastapi │
|
|
95
|
+
│ Dependency 2 │ uvicorn │
|
|
96
|
+
│ Dependency 3 │ sqlalchemy │
|
|
97
|
+
│ Dependency 4 │ alembic │
|
|
98
|
+
│ Dependency 5 │ pytest │
|
|
99
|
+
│ Dependency 6 │ pydantic │
|
|
100
|
+
│ Dependency 7 │ pydantic-settings │
|
|
101
|
+
└──────────────┴───────────────────┘
|
|
102
|
+
|
|
103
|
+
FULL Stack
|
|
104
|
+
┌──────────────┬───────────────────┐
|
|
105
|
+
│ Dependency 1 │ fastapi │
|
|
106
|
+
│ Dependency 2 │ uvicorn │
|
|
107
|
+
│ Dependency 3 │ sqlalchemy │
|
|
108
|
+
│ Dependency 4 │ alembic │
|
|
109
|
+
│ Dependency 5 │ pytest │
|
|
110
|
+
│ Dependency 6 │ redis │
|
|
111
|
+
│ Dependency 7 │ celery │
|
|
112
|
+
│ Dependency 8 │ pydantic │
|
|
113
|
+
│ Dependency 9 │ pydantic-settings │
|
|
114
|
+
└──────────────┴───────────────────┘
|
|
115
|
+
|
|
116
|
+
Select stack (minimal, standard, full): minimal
|
|
117
|
+
Do you want to proceed with project creation? [y/N]: y
|
|
118
|
+
FastAPI project will deploy at '~your-project-path~'
|
|
119
|
+
|
|
120
|
+
╭──────────────────────── Info ────────────────────────╮
|
|
121
|
+
│ ℹ Injected metadata into setup.py │
|
|
122
|
+
╰──────────────────────────────────────────────────────╯
|
|
123
|
+
╭──────────────────────── Info ────────────────────────╮
|
|
124
|
+
│ ℹ Injected metadata into config file │
|
|
125
|
+
╰──────────────────────────────────────────────────────╯
|
|
126
|
+
|
|
127
|
+
Creating Project:
|
|
128
|
+
my-awesome-project
|
|
129
|
+
┌───────────────────┬───────────┐
|
|
130
|
+
│ Component │ Collected │
|
|
131
|
+
│ fastapi │ ✓ │
|
|
132
|
+
│ uvicorn │ ✓ │
|
|
133
|
+
│ pydantic │ ✓ │
|
|
134
|
+
│ pydantic-settings │ ✓ │
|
|
135
|
+
└───────────────────┴───────────┘
|
|
136
|
+
|
|
137
|
+
Creating virtual environment...
|
|
138
|
+
|
|
139
|
+
╭──────────────────────── Info ────────────────────────╮
|
|
140
|
+
│ ℹ venv created at │
|
|
141
|
+
│ ~your-project-path~/my-awesome-project/.venv │
|
|
142
|
+
│ To activate the virtual environment, run: │
|
|
143
|
+
│ │
|
|
144
|
+
│ source │
|
|
145
|
+
│ ~your-project-path~/my-awesome-project/.venv/bin/act │
|
|
146
|
+
│ ivate │
|
|
147
|
+
╰──────────────────────────────────────────────────────╯
|
|
148
|
+
|
|
149
|
+
Installing dependencies...
|
|
150
|
+
⠙ Setting up project environment...Collecting <packages~>
|
|
151
|
+
|
|
152
|
+
---> 100%
|
|
153
|
+
|
|
154
|
+
╭─────────────────────── Success ───────────────────────╮
|
|
155
|
+
│ ✨ Dependencies installed successfully │
|
|
156
|
+
╰───────────────────────────────────────────────────────╯
|
|
157
|
+
╭─────────────────────── Success ───────────────────────╮
|
|
158
|
+
│ ✨ FastAPI project 'my-awesome-project' has been │
|
|
159
|
+
│ created successfully and saved to │
|
|
160
|
+
│ ~your-project-path~! │
|
|
161
|
+
╰───────────────────────────────────────────────────────╯
|
|
162
|
+
╭──────────────────────── Info ────────────────────────╮
|
|
163
|
+
│ ℹ To start your project, run 'fastkit runserver' at │
|
|
164
|
+
│ newly created FastAPI project directory │
|
|
165
|
+
╰──────────────────────────────────────────────────────╯
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This command will create a new FastAPI project workspace environment with Python virtual environment.
|
|
169
|
+
|
|
170
|
+
### Add a new route to the FastAPI project
|
|
171
|
+
|
|
172
|
+
`FastAPI-fastkit` makes it easy to expand your FastAPI project.
|
|
173
|
+
|
|
174
|
+
Add a new route endpoint to your FastAPI project with:
|
|
175
|
+
|
|
176
|
+
```console
|
|
177
|
+
$ fastkit addroute my-awesome-project user
|
|
178
|
+
Adding New Route
|
|
179
|
+
┌──────────────────┬──────────────────────────────────────────┐
|
|
180
|
+
│ Project │ my-awesome-project │
|
|
181
|
+
│ Route Name │ user │
|
|
182
|
+
│ Target Directory │ ~your-project-path~ │
|
|
183
|
+
└──────────────────┴──────────────────────────────────────────┘
|
|
184
|
+
|
|
185
|
+
Do you want to add route 'user' to project 'my-awesome-project'? [Y/n]: y
|
|
186
|
+
|
|
187
|
+
╭──────────────────────── Info ────────────────────────╮
|
|
188
|
+
│ ℹ Updated main.py to include the API router │
|
|
189
|
+
╰──────────────────────────────────────────────────────╯
|
|
190
|
+
╭─────────────────────── Success ───────────────────────╮
|
|
191
|
+
│ ✨ Successfully added new route 'user' to project │
|
|
192
|
+
│ `my-awesome-project` │
|
|
193
|
+
╰───────────────────────────────────────────────────────╯
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Place a structured FastAPI demo project immediately
|
|
197
|
+
|
|
198
|
+
You can also start with a structured FastAPI demo project.
|
|
199
|
+
|
|
200
|
+
Demo projects are consist of various tech stacks with simple item CRUD endpoints implemented.
|
|
201
|
+
|
|
202
|
+
Place a structured FastAPI demo project immediately with:
|
|
203
|
+
|
|
204
|
+
```console
|
|
205
|
+
$ fastkit startdemo
|
|
206
|
+
Enter the project name: my-awesome-demo
|
|
207
|
+
Enter the author name: John Doe
|
|
208
|
+
Enter the author email: john@example.com
|
|
209
|
+
Enter the project description: My awesome FastAPI demo
|
|
210
|
+
Deploying FastAPI project using 'fastapi-default' template
|
|
211
|
+
Template path:
|
|
212
|
+
/~fastapi_fastkit-package-path~/fastapi_project_template/fastapi-default
|
|
213
|
+
|
|
214
|
+
Project Information
|
|
215
|
+
┌──────────────┬─────────────────────────┐
|
|
216
|
+
│ Project Name │ my-awesome-demo │
|
|
217
|
+
│ Author │ John Doe │
|
|
218
|
+
│ Author Email │ john@example.com │
|
|
219
|
+
│ Description │ My awesome FastAPI demo │
|
|
220
|
+
└──────────────┴─────────────────────────┘
|
|
221
|
+
|
|
222
|
+
Template Dependencies
|
|
223
|
+
┌──────────────┬───────────────────┐
|
|
224
|
+
│ Dependency 1 │ fastapi │
|
|
225
|
+
│ Dependency 2 │ uvicorn │
|
|
226
|
+
│ Dependency 3 │ pydantic │
|
|
227
|
+
│ Dependency 4 │ pydantic-settings │
|
|
228
|
+
│ Dependency 5 │ python-dotenv │
|
|
229
|
+
└──────────────┴───────────────────┘
|
|
230
|
+
|
|
231
|
+
Do you want to proceed with project creation? [y/N]: y
|
|
232
|
+
FastAPI template project will deploy at '~your-project-path~'
|
|
233
|
+
|
|
234
|
+
---> 100%
|
|
235
|
+
|
|
236
|
+
╭─────────────────────── Success ───────────────────────╮
|
|
237
|
+
│ ✨ Dependencies installed successfully │
|
|
238
|
+
╰───────────────────────────────────────────────────────╯
|
|
239
|
+
╭─────────────────────── Success ───────────────────────╮
|
|
240
|
+
│ ✨ FastAPI project 'my-awesome-demo' from │
|
|
241
|
+
│ 'fastapi-default' has been created and saved to │
|
|
242
|
+
│ ~your-project-path~! │
|
|
243
|
+
╰───────────────────────────────────────────────────────╯
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
To view the list of available FastAPI demos, check with:
|
|
247
|
+
|
|
248
|
+
```console
|
|
249
|
+
$ fastkit list-templates
|
|
250
|
+
Available Templates
|
|
251
|
+
┌─────────────────────────┬───────────────────────────────────┐
|
|
252
|
+
│ fastapi-custom-response │ Async Item Management API with │
|
|
253
|
+
│ │ Custom Response System │
|
|
254
|
+
│ fastapi-dockerized │ Dockerized FastAPI Item │
|
|
255
|
+
│ │ Management API │
|
|
256
|
+
│ fastapi-empty │ No description │
|
|
257
|
+
│ fastapi-async-crud │ Async Item Management API Server │
|
|
258
|
+
│ fastapi-psql-orm │ Dockerized FastAPI Item │
|
|
259
|
+
│ │ Management API with PostgreSQL │
|
|
260
|
+
│ fastapi-default │ Simple FastAPI Project │
|
|
261
|
+
└─────────────────────────┴───────────────────────────────────┘
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Contributing
|
|
265
|
+
|
|
266
|
+
We welcome contributions from the community! FastAPI-fastkit is designed to help newcomers to Python and FastAPI, and your contributions can make a significant impact.
|
|
267
|
+
|
|
268
|
+
### For Contributors
|
|
269
|
+
|
|
270
|
+
If you want to contribute to this project, we've made it easy to get started:
|
|
271
|
+
|
|
272
|
+
1. **Quick Development Setup:**
|
|
273
|
+
|
|
274
|
+
fork or clone this repository:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
git clone https://github.com/bnbong/FastAPI-fastkit.git
|
|
278
|
+
cd FastAPI-fastkit
|
|
279
|
+
make dev-setup
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
2. **Available Development Commands:**
|
|
283
|
+
|
|
284
|
+
This project uses [Makefile](https://www.gnu.org/software/make/) to manage the development process.
|
|
285
|
+
|
|
286
|
+
You can use the following commands to help you get started:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
make help # See all available commands
|
|
290
|
+
make dev-check # Run all checks before submitting
|
|
291
|
+
make quick-test # Quick test after changes
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
3. **Read our contribution guidelines:**
|
|
295
|
+
|
|
296
|
+
For other contribution guidelines, please refer to the following files:
|
|
297
|
+
|
|
298
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) - Detailed contribution guide
|
|
299
|
+
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Project principles
|
|
300
|
+
- [SECURITY.md](SECURITY.md) - Security guidelines
|
|
301
|
+
|
|
302
|
+
### What You Can Contribute
|
|
303
|
+
|
|
304
|
+
- 🚀 **New FastAPI templates** - Add templates for different use cases
|
|
305
|
+
- 🐛 **Bug fixes** - Help us improve stability and reliability
|
|
306
|
+
- 📚 **Documentation** - Improve guides, examples, and translations
|
|
307
|
+
- 🧪 **Tests** - Increase test coverage and add integration tests
|
|
308
|
+
- 💡 **Features** - Suggest and implement new CLI features
|
|
309
|
+
|
|
310
|
+
## Significance of FastAPI-fastkit
|
|
311
|
+
|
|
312
|
+
FastAPI-fastkit aims to provide a fast and easy-to-use starter kit for new users of Python and FastAPI.
|
|
313
|
+
|
|
314
|
+
This idea was initiated with the aim of full fill to help FastAPI newcomers to learn from the beginning, which is the production significance of the FastAPI-cli package added with the [FastAPI 0.111.0 version update](https://github.com/fastapi/fastapi/releases/tag/0.111.0).
|
|
315
|
+
|
|
316
|
+
As one person who has been using and loving FastAPI for a long time, I wanted to develop a project that could help me a little bit to practice [the wonderful motivation](https://github.com/fastapi/fastapi/pull/11522#issuecomment-2264639417) that FastAPI developer [tiangolo](https://github.com/tiangolo) has.
|
|
317
|
+
|
|
318
|
+
## License
|
|
319
|
+
|
|
320
|
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/bnbong/FastAPI-fastkit/blob/main/LICENSE) file for details.
|