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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"id": 1,
|
|
4
|
-
"name": "Test Item 1",
|
|
5
|
-
"price": 20.0,
|
|
6
|
-
"category": "test"
|
|
7
|
-
}
|
|
8
|
-
]
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"name": "Test Item 1",
|
|
5
|
+
"price": 20.0,
|
|
6
|
+
"category": "test"
|
|
7
|
+
}
|
|
8
|
+
]
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# --------------------------------------------------------------------------
|
|
2
|
-
# pytest runtime configuration module
|
|
3
|
-
# --------------------------------------------------------------------------
|
|
4
|
-
from collections.abc import Generator
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
import json
|
|
8
|
-
import pytest
|
|
9
|
-
from fastapi.testclient import TestClient
|
|
10
|
-
|
|
11
|
-
from src.main import app
|
|
12
|
-
|
|
13
|
-
MOCK_FILE = os.path.join(os.path.dirname(__file__), "../src/mocks/mock_items.json")
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@pytest.fixture(autouse=True)
|
|
17
|
-
def reset_mock_data():
|
|
18
|
-
initial_data = [
|
|
19
|
-
{"id": 1, "name": "Test Item 1", "price": 10.5, "category": "test"},
|
|
20
|
-
{"id": 2, "name": "Test Item 2", "price": 20.0, "category": "test"},
|
|
21
|
-
]
|
|
22
|
-
with open(MOCK_FILE, "w") as file:
|
|
23
|
-
json.dump(initial_data, file)
|
|
24
|
-
yield
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@pytest.fixture(scope="module")
|
|
28
|
-
def client() -> Generator[TestClient, None, None]:
|
|
29
|
-
with TestClient(app) as c:
|
|
30
|
-
yield c
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
# pytest runtime configuration module
|
|
3
|
+
# --------------------------------------------------------------------------
|
|
4
|
+
from collections.abc import Generator
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import json
|
|
8
|
+
import pytest
|
|
9
|
+
from fastapi.testclient import TestClient
|
|
10
|
+
|
|
11
|
+
from src.main import app
|
|
12
|
+
|
|
13
|
+
MOCK_FILE = os.path.join(os.path.dirname(__file__), "../src/mocks/mock_items.json")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@pytest.fixture(autouse=True)
|
|
17
|
+
def reset_mock_data():
|
|
18
|
+
initial_data = [
|
|
19
|
+
{"id": 1, "name": "Test Item 1", "price": 10.5, "category": "test"},
|
|
20
|
+
{"id": 2, "name": "Test Item 2", "price": 20.0, "category": "test"},
|
|
21
|
+
]
|
|
22
|
+
with open(MOCK_FILE, "w") as file:
|
|
23
|
+
json.dump(initial_data, file)
|
|
24
|
+
yield
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.fixture(scope="module")
|
|
28
|
+
def client() -> Generator[TestClient, None, None]:
|
|
29
|
+
with TestClient(app) as c:
|
|
30
|
+
yield c
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
# --------------------------------------------------------------------------
|
|
2
|
-
# Item endpoint testcases
|
|
3
|
-
# --------------------------------------------------------------------------
|
|
4
|
-
import json
|
|
5
|
-
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_read_all_items(client):
|
|
10
|
-
response = client.get("/items")
|
|
11
|
-
assert response.status_code == 200
|
|
12
|
-
assert len(response.json()) == 2
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_read_item_success(client):
|
|
16
|
-
response = client.get("/items/1")
|
|
17
|
-
assert response.status_code == 200
|
|
18
|
-
assert response.json()["name"] == "Test Item 1"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def test_read_item_not_found(client):
|
|
22
|
-
response = client.get("/items/999")
|
|
23
|
-
assert response.status_code == 404
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def test_create_item(client):
|
|
27
|
-
new_item = {"name": "New Item", "price": 30.0, "category": "new"}
|
|
28
|
-
response = client.post("/items", json=new_item)
|
|
29
|
-
assert response.status_code == 201
|
|
30
|
-
assert response.json()["id"] == 3
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def test_update_item(client):
|
|
34
|
-
updated_data = {"name": "Updated Item", "price": 15.0, "category": "updated"}
|
|
35
|
-
response = client.put("/items/1", json=updated_data)
|
|
36
|
-
assert response.status_code == 200
|
|
37
|
-
assert response.json()["name"] == "Updated Item"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def test_delete_item(client):
|
|
41
|
-
response = client.delete("/items/1")
|
|
42
|
-
assert response.status_code == 200
|
|
43
|
-
response = client.get("/items/1")
|
|
44
|
-
assert response.status_code == 404
|
|
1
|
+
# --------------------------------------------------------------------------
|
|
2
|
+
# Item endpoint testcases
|
|
3
|
+
# --------------------------------------------------------------------------
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_read_all_items(client):
|
|
10
|
+
response = client.get("/items")
|
|
11
|
+
assert response.status_code == 200
|
|
12
|
+
assert len(response.json()) == 2
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_read_item_success(client):
|
|
16
|
+
response = client.get("/items/1")
|
|
17
|
+
assert response.status_code == 200
|
|
18
|
+
assert response.json()["name"] == "Test Item 1"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_read_item_not_found(client):
|
|
22
|
+
response = client.get("/items/999")
|
|
23
|
+
assert response.status_code == 404
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_create_item(client):
|
|
27
|
+
new_item = {"name": "New Item", "price": 30.0, "category": "new"}
|
|
28
|
+
response = client.post("/items", json=new_item)
|
|
29
|
+
assert response.status_code == 201
|
|
30
|
+
assert response.json()["id"] == 3
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_update_item(client):
|
|
34
|
+
updated_data = {"name": "Updated Item", "price": 15.0, "category": "updated"}
|
|
35
|
+
response = client.put("/items/1", json=updated_data)
|
|
36
|
+
assert response.status_code == 200
|
|
37
|
+
assert response.json()["name"] == "Updated Item"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_delete_item(client):
|
|
41
|
+
response = client.delete("/items/1")
|
|
42
|
+
assert response.status_code == 200
|
|
43
|
+
response = client.get("/items/1")
|
|
44
|
+
assert response.status_code == 404
|
|
@@ -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
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
FROM python:3.12-slim
|
|
2
|
-
|
|
3
|
-
WORKDIR /app
|
|
4
|
-
|
|
5
|
-
RUN apt-get update && \
|
|
6
|
-
apt-get install -y --no-install-recommends \
|
|
7
|
-
build-essential \
|
|
8
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
-
|
|
10
|
-
COPY requirements.txt .
|
|
11
|
-
COPY setup.py .
|
|
12
|
-
COPY src/ src/
|
|
13
|
-
COPY tests/ tests/
|
|
14
|
-
|
|
15
|
-
RUN pip install --no-cache-dir -r requirements.txt
|
|
16
|
-
RUN pip install --no-cache-dir -e .
|
|
17
|
-
|
|
18
|
-
ENV PYTHONPATH=/app
|
|
19
|
-
ENV ENVIRONMENT=production
|
|
20
|
-
|
|
21
|
-
EXPOSE 8000
|
|
22
|
-
|
|
23
|
-
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
RUN apt-get update && \
|
|
6
|
+
apt-get install -y --no-install-recommends \
|
|
7
|
+
build-essential \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
COPY requirements.txt .
|
|
11
|
+
COPY setup.py .
|
|
12
|
+
COPY src/ src/
|
|
13
|
+
COPY tests/ tests/
|
|
14
|
+
|
|
15
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
16
|
+
RUN pip install --no-cache-dir -e .
|
|
17
|
+
|
|
18
|
+
ENV PYTHONPATH=/app
|
|
19
|
+
ENV ENVIRONMENT=production
|
|
20
|
+
|
|
21
|
+
EXPOSE 8000
|
|
22
|
+
|
|
23
|
+
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
# Dockerized FastAPI Item Management API
|
|
2
|
-
|
|
3
|
-
This project is a Docker containerized FastAPI-based item management API application.
|
|
4
|
-
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
- Docker
|
|
8
|
-
|
|
9
|
-
## Tech Stack
|
|
10
|
-
|
|
11
|
-
- Python 3.12+
|
|
12
|
-
- FastAPI + uvicorn
|
|
13
|
-
- Docker
|
|
14
|
-
- pydantic 2 & pydantic-settings
|
|
15
|
-
- pytest
|
|
16
|
-
- mypy + black + isort
|
|
17
|
-
|
|
18
|
-
## Project Structure
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
.
|
|
22
|
-
├── Dockerfile
|
|
23
|
-
├── README.md
|
|
24
|
-
├── requirements.txt
|
|
25
|
-
├── setup.py
|
|
26
|
-
├── scripts
|
|
27
|
-
│ └── run-server.sh
|
|
28
|
-
├── src
|
|
29
|
-
│ ├── main.py
|
|
30
|
-
│ ├── schemas
|
|
31
|
-
│ │ └── items.py
|
|
32
|
-
│ ├── mocks
|
|
33
|
-
│ │ └── mock_items.json
|
|
34
|
-
│ ├── crud
|
|
35
|
-
│ │ └── items.py
|
|
36
|
-
│ ├── core
|
|
37
|
-
│ │ └── config.py
|
|
38
|
-
│ └── api
|
|
39
|
-
│ ├── api.py
|
|
40
|
-
│ └── routes
|
|
41
|
-
│ └── items.py
|
|
42
|
-
└── tests
|
|
43
|
-
├── __init__.py
|
|
44
|
-
├── test_items.py
|
|
45
|
-
└── conftest.py
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## How to run
|
|
49
|
-
|
|
50
|
-
### Run with Docker
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
# Build image
|
|
54
|
-
$ docker build -t fastapi-item-app .
|
|
55
|
-
|
|
56
|
-
# Run container
|
|
57
|
-
$ docker run -d --name item-container -p 8000:8000 fastapi-item-app
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Run with instance
|
|
61
|
-
|
|
62
|
-
At venv, run command below:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
# Start development server (using script)
|
|
66
|
-
$ bash scripts/run-server.sh
|
|
67
|
-
|
|
68
|
-
# Manual run
|
|
69
|
-
$ uvicorn src.main:app --reload
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
After running server instance, you can check API documentation below:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
<domain:port>/docs # Swagger format
|
|
76
|
-
<domain:port>/redoc # ReDoc format
|
|
77
|
-
|
|
78
|
-
# example
|
|
79
|
-
http://127.0.0.1:8000/docs
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## API Endpoints
|
|
83
|
-
|
|
84
|
-
| Method | Endpoint | Description |
|
|
85
|
-
|--------|------------------|----------------------------|
|
|
86
|
-
| GET | `/items/` | List all items |
|
|
87
|
-
| GET | `/items/{id}` | Get single item |
|
|
88
|
-
| POST | `/items/` | Create new item |
|
|
89
|
-
| PUT | `/items/{id}` | Update existing item |
|
|
90
|
-
| DELETE | `/items/{id}` | Delete item |
|
|
91
|
-
|
|
92
|
-
## Key Features
|
|
93
|
-
|
|
94
|
-
- Initial data loading with mock data
|
|
95
|
-
- Pydantic model-based data validation
|
|
96
|
-
- Demo CRUD operations implementation (Item CRUD)
|
|
97
|
-
- Integrated test cases
|
|
98
|
-
|
|
99
|
-
## Running Tests
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
# Run all tests
|
|
103
|
-
$ pytest tests/
|
|
104
|
-
|
|
105
|
-
# Run specific test file
|
|
106
|
-
$ pytest tests/test_items.py -v
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
For other FastAPI guides, please refer <https://fastapi.tiangolo.com/tutorial/>
|
|
110
|
-
|
|
111
|
-
# Project Origin
|
|
112
|
-
|
|
113
|
-
This project was created based on the template from the [FastAPI-fastkit](https://github.com/bnbong/FastAPI-fastkit) project.
|
|
114
|
-
|
|
115
|
-
The `FastAPI-fastkit` is an open-source project that helps Python and FastAPI beginners quickly set up a FastAPI-based application development environment in a framework-like structure.
|
|
116
|
-
|
|
117
|
-
### Template Information
|
|
118
|
-
- Template creator: [bnbong](mailto:bbbong9@gmail.com)
|
|
119
|
-
- FastAPI-fastkit project maintainer: [bnbong](mailto:bbbong9@gmail.com)
|
|
1
|
+
# Dockerized FastAPI Item Management API
|
|
2
|
+
|
|
3
|
+
This project is a Docker containerized FastAPI-based item management API application.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Docker
|
|
8
|
+
|
|
9
|
+
## Tech Stack
|
|
10
|
+
|
|
11
|
+
- Python 3.12+
|
|
12
|
+
- FastAPI + uvicorn
|
|
13
|
+
- Docker
|
|
14
|
+
- pydantic 2 & pydantic-settings
|
|
15
|
+
- pytest
|
|
16
|
+
- mypy + black + isort
|
|
17
|
+
|
|
18
|
+
## Project Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
.
|
|
22
|
+
├── Dockerfile
|
|
23
|
+
├── README.md
|
|
24
|
+
├── requirements.txt
|
|
25
|
+
├── setup.py
|
|
26
|
+
├── scripts
|
|
27
|
+
│ └── run-server.sh
|
|
28
|
+
├── src
|
|
29
|
+
│ ├── main.py
|
|
30
|
+
│ ├── schemas
|
|
31
|
+
│ │ └── items.py
|
|
32
|
+
│ ├── mocks
|
|
33
|
+
│ │ └── mock_items.json
|
|
34
|
+
│ ├── crud
|
|
35
|
+
│ │ └── items.py
|
|
36
|
+
│ ├── core
|
|
37
|
+
│ │ └── config.py
|
|
38
|
+
│ └── api
|
|
39
|
+
│ ├── api.py
|
|
40
|
+
│ └── routes
|
|
41
|
+
│ └── items.py
|
|
42
|
+
└── tests
|
|
43
|
+
├── __init__.py
|
|
44
|
+
├── test_items.py
|
|
45
|
+
└── conftest.py
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## How to run
|
|
49
|
+
|
|
50
|
+
### Run with Docker
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Build image
|
|
54
|
+
$ docker build -t fastapi-item-app .
|
|
55
|
+
|
|
56
|
+
# Run container
|
|
57
|
+
$ docker run -d --name item-container -p 8000:8000 fastapi-item-app
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Run with instance
|
|
61
|
+
|
|
62
|
+
At venv, run command below:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Start development server (using script)
|
|
66
|
+
$ bash scripts/run-server.sh
|
|
67
|
+
|
|
68
|
+
# Manual run
|
|
69
|
+
$ uvicorn src.main:app --reload
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
After running server instance, you can check API documentation below:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
<domain:port>/docs # Swagger format
|
|
76
|
+
<domain:port>/redoc # ReDoc format
|
|
77
|
+
|
|
78
|
+
# example
|
|
79
|
+
http://127.0.0.1:8000/docs
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API Endpoints
|
|
83
|
+
|
|
84
|
+
| Method | Endpoint | Description |
|
|
85
|
+
|--------|------------------|----------------------------|
|
|
86
|
+
| GET | `/items/` | List all items |
|
|
87
|
+
| GET | `/items/{id}` | Get single item |
|
|
88
|
+
| POST | `/items/` | Create new item |
|
|
89
|
+
| PUT | `/items/{id}` | Update existing item |
|
|
90
|
+
| DELETE | `/items/{id}` | Delete item |
|
|
91
|
+
|
|
92
|
+
## Key Features
|
|
93
|
+
|
|
94
|
+
- Initial data loading with mock data
|
|
95
|
+
- Pydantic model-based data validation
|
|
96
|
+
- Demo CRUD operations implementation (Item CRUD)
|
|
97
|
+
- Integrated test cases
|
|
98
|
+
|
|
99
|
+
## Running Tests
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Run all tests
|
|
103
|
+
$ pytest tests/
|
|
104
|
+
|
|
105
|
+
# Run specific test file
|
|
106
|
+
$ pytest tests/test_items.py -v
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For other FastAPI guides, please refer <https://fastapi.tiangolo.com/tutorial/>
|
|
110
|
+
|
|
111
|
+
# Project Origin
|
|
112
|
+
|
|
113
|
+
This project was created based on the template from the [FastAPI-fastkit](https://github.com/bnbong/FastAPI-fastkit) project.
|
|
114
|
+
|
|
115
|
+
The `FastAPI-fastkit` is an open-source project that helps Python and FastAPI beginners quickly set up a FastAPI-based application development environment in a framework-like structure.
|
|
116
|
+
|
|
117
|
+
### Template Information
|
|
118
|
+
- Template creator: [bnbong](mailto:bbbong9@gmail.com)
|
|
119
|
+
- FastAPI-fastkit project maintainer: [bnbong](mailto:bbbong9@gmail.com)
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
annotated-types==0.7.0
|
|
2
|
-
anyio==4.8.0
|
|
3
|
-
black==25.1.0
|
|
4
|
-
certifi==2025.1.31
|
|
5
|
-
click==8.1.8
|
|
6
|
-
fastapi==0.115.8
|
|
7
|
-
h11==0.14.0
|
|
8
|
-
httpcore==1.0.7
|
|
9
|
-
httptools==0.6.4
|
|
10
|
-
httpx==0.28.1
|
|
11
|
-
idna==3.10
|
|
12
|
-
iniconfig==2.0.0
|
|
13
|
-
isort==6.0.0
|
|
14
|
-
mypy==1.15.0
|
|
15
|
-
mypy-extensions==1.0.0
|
|
16
|
-
packaging==24.2
|
|
17
|
-
pathspec==0.12.1
|
|
18
|
-
platformdirs==4.3.6
|
|
19
|
-
pluggy==1.5.0
|
|
20
|
-
pydantic==2.10.6
|
|
21
|
-
pydantic-settings==2.7.1
|
|
22
|
-
pydantic_core==2.27.2
|
|
23
|
-
pytest==8.3.4
|
|
24
|
-
python-dotenv==1.0.1
|
|
25
|
-
PyYAML==6.0.2
|
|
26
|
-
setuptools==75.8.0
|
|
27
|
-
setuptools_scm==8.1.0
|
|
28
|
-
sniffio==1.3.1
|
|
29
|
-
SQLAlchemy==2.0.38
|
|
30
|
-
sqlmodel==0.0.22
|
|
31
|
-
starlette==0.45.3
|
|
32
|
-
typing_extensions==4.12.2
|
|
33
|
-
uvicorn==0.34.0
|
|
34
|
-
uvloop==0.21.0
|
|
35
|
-
watchfiles==1.0.4
|
|
36
|
-
websockets==15.0
|
|
1
|
+
annotated-types==0.7.0
|
|
2
|
+
anyio==4.8.0
|
|
3
|
+
black==25.1.0
|
|
4
|
+
certifi==2025.1.31
|
|
5
|
+
click==8.1.8
|
|
6
|
+
fastapi==0.115.8
|
|
7
|
+
h11==0.14.0
|
|
8
|
+
httpcore==1.0.7
|
|
9
|
+
httptools==0.6.4
|
|
10
|
+
httpx==0.28.1
|
|
11
|
+
idna==3.10
|
|
12
|
+
iniconfig==2.0.0
|
|
13
|
+
isort==6.0.0
|
|
14
|
+
mypy==1.15.0
|
|
15
|
+
mypy-extensions==1.0.0
|
|
16
|
+
packaging==24.2
|
|
17
|
+
pathspec==0.12.1
|
|
18
|
+
platformdirs==4.3.6
|
|
19
|
+
pluggy==1.5.0
|
|
20
|
+
pydantic==2.10.6
|
|
21
|
+
pydantic-settings==2.7.1
|
|
22
|
+
pydantic_core==2.27.2
|
|
23
|
+
pytest==8.3.4
|
|
24
|
+
python-dotenv==1.0.1
|
|
25
|
+
PyYAML==6.0.2
|
|
26
|
+
setuptools==75.8.0
|
|
27
|
+
setuptools_scm==8.1.0
|
|
28
|
+
sniffio==1.3.1
|
|
29
|
+
SQLAlchemy==2.0.38
|
|
30
|
+
sqlmodel==0.0.22
|
|
31
|
+
starlette==0.45.3
|
|
32
|
+
typing_extensions==4.12.2
|
|
33
|
+
uvicorn==0.34.0
|
|
34
|
+
uvloop==0.21.0
|
|
35
|
+
watchfiles==1.0.4
|
|
36
|
+
websockets==15.0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -x
|
|
3
|
-
|
|
4
|
-
black .
|
|
5
|
-
isort .
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -x
|
|
3
|
+
|
|
4
|
+
black .
|
|
5
|
+
isort .
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -x
|
|
3
|
-
|
|
4
|
-
black . --check
|
|
5
|
-
mypy src
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -x
|
|
3
|
+
|
|
4
|
+
black . --check
|
|
5
|
+
mypy src
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -e
|
|
4
|
-
set -x
|
|
5
|
-
|
|
6
|
-
source .venv/bin/activate
|
|
7
|
-
|
|
8
|
-
uvicorn src.main:app --reload
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
set -x
|
|
5
|
+
|
|
6
|
+
source .venv/bin/activate
|
|
7
|
+
|
|
8
|
+
uvicorn src.main:app --reload
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
set -e
|
|
4
|
-
set -x
|
|
5
|
-
|
|
6
|
-
pytest
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
set -x
|
|
5
|
+
|
|
6
|
+
pytest
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
[mypy]
|
|
2
|
-
warn_unused_configs = true
|
|
3
|
-
ignore_missing_imports = true
|
|
4
|
-
|
|
5
|
-
[isort]
|
|
6
|
-
profile = black
|
|
7
|
-
line_length=100
|
|
8
|
-
virtual_env=venv
|
|
9
|
-
|
|
10
|
-
[tool:pytest]
|
|
11
|
-
pythonpath = src
|
|
12
|
-
testpaths = tests
|
|
13
|
-
python_files = test_*.py
|
|
1
|
+
[mypy]
|
|
2
|
+
warn_unused_configs = true
|
|
3
|
+
ignore_missing_imports = true
|
|
4
|
+
|
|
5
|
+
[isort]
|
|
6
|
+
profile = black
|
|
7
|
+
line_length=100
|
|
8
|
+
virtual_env=venv
|
|
9
|
+
|
|
10
|
+
[tool:pytest]
|
|
11
|
+
pythonpath = src
|
|
12
|
+
testpaths = tests
|
|
13
|
+
python_files = test_*.py
|