bisslog-flask 0.0.1__tar.gz
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.
- bisslog_flask-0.0.1/.github/workflows/publish-pypi.yml +66 -0
- bisslog_flask-0.0.1/.github/workflows/publish-test-pypi.yml +76 -0
- bisslog_flask-0.0.1/.github/workflows/receive-changes.yml +29 -0
- bisslog_flask-0.0.1/.gitignore +175 -0
- bisslog_flask-0.0.1/LICENSE +21 -0
- bisslog_flask-0.0.1/PKG-INFO +141 -0
- bisslog_flask-0.0.1/README.md +120 -0
- bisslog_flask-0.0.1/bisslog_flask/__init__.py +26 -0
- bisslog_flask-0.0.1/bisslog_flask/initializer/__init__.py +0 -0
- bisslog_flask-0.0.1/bisslog_flask/initializer/bisslog_flask_http_resolver.py +186 -0
- bisslog_flask-0.0.1/bisslog_flask/initializer/bisslog_flask_resolver.py +46 -0
- bisslog_flask-0.0.1/bisslog_flask/initializer/bisslog_flask_ws_resolver.py +76 -0
- bisslog_flask-0.0.1/bisslog_flask/initializer/init_flask_app_manager.py +123 -0
- bisslog_flask-0.0.1/bisslog_flask/socket_helper/__init__.py +0 -0
- bisslog_flask-0.0.1/bisslog_flask/socket_helper/socket_helper.py +106 -0
- bisslog_flask-0.0.1/bisslog_flask.egg-info/PKG-INFO +141 -0
- bisslog_flask-0.0.1/bisslog_flask.egg-info/SOURCES.txt +28 -0
- bisslog_flask-0.0.1/bisslog_flask.egg-info/dependency_links.txt +1 -0
- bisslog_flask-0.0.1/bisslog_flask.egg-info/requires.txt +9 -0
- bisslog_flask-0.0.1/bisslog_flask.egg-info/top_level.txt +1 -0
- bisslog_flask-0.0.1/pylintrc +567 -0
- bisslog_flask-0.0.1/pyproject.toml +37 -0
- bisslog_flask-0.0.1/requirements/requirements-flask-optional.txt +2 -0
- bisslog_flask-0.0.1/requirements.txt +3 -0
- bisslog_flask-0.0.1/setup.cfg +4 -0
- bisslog_flask-0.0.1/tests/__init__.py +0 -0
- bisslog_flask-0.0.1/tests/unit/__init__.py +0 -0
- bisslog_flask-0.0.1/tests/unit/test_http_resolver.py +97 -0
- bisslog_flask-0.0.1/tests/unit/test_init_app_manager.py +71 -0
- bisslog_flask-0.0.1/tests/unit/test_ws_resolver.py +77 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
name: Deploy to PyPI
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
run-changes-reception:
|
9
|
+
uses: darwinhc/bisslog-flask/.github/workflows/receive-changes.yml@master
|
10
|
+
|
11
|
+
determine-version:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
outputs:
|
14
|
+
version: ${{ steps.set-version.outputs.VERSION }}
|
15
|
+
steps:
|
16
|
+
- name: Checkout repository
|
17
|
+
uses: actions/checkout@v4
|
18
|
+
with:
|
19
|
+
fetch-depth: 0
|
20
|
+
|
21
|
+
- name: Install dependencies
|
22
|
+
run: |
|
23
|
+
python -m pip install --upgrade pip
|
24
|
+
pip install setuptools_scm
|
25
|
+
|
26
|
+
- name: Determine version for TestPyPI
|
27
|
+
id: set-version
|
28
|
+
run: |
|
29
|
+
VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version(version_scheme='post-release', local_scheme='no-local-version'))")
|
30
|
+
VERSION=$(echo "$VERSION" | sed -E 's/\.post([0-9]+)/.\1.${{ github.run_number }}/')
|
31
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
32
|
+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
33
|
+
|
34
|
+
deploy:
|
35
|
+
runs-on: ubuntu-latest
|
36
|
+
needs: [run-changes-reception, determine-version]
|
37
|
+
|
38
|
+
steps:
|
39
|
+
- name: Checkout code
|
40
|
+
uses: actions/checkout@v4
|
41
|
+
with:
|
42
|
+
fetch-depth: 0
|
43
|
+
|
44
|
+
- name: Set up Python
|
45
|
+
uses: actions/setup-python@v4
|
46
|
+
with:
|
47
|
+
python-version: "3.x"
|
48
|
+
|
49
|
+
- name: Install dependencies
|
50
|
+
run: |
|
51
|
+
python -m pip install --upgrade pip
|
52
|
+
pip install build twine setuptools_scm
|
53
|
+
- name: Printing version to build
|
54
|
+
run: echo ${{ needs.determine-version.outputs.version }}
|
55
|
+
|
56
|
+
- name: Build package with correct version
|
57
|
+
run: |
|
58
|
+
python -m build
|
59
|
+
env:
|
60
|
+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.determine-version.outputs.version }}
|
61
|
+
|
62
|
+
- name: Publish to PyPI
|
63
|
+
env:
|
64
|
+
TWINE_USERNAME: __token__
|
65
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
66
|
+
run: twine upload dist/*
|
@@ -0,0 +1,76 @@
|
|
1
|
+
name: Deploy to TestPyPI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- qa
|
7
|
+
paths:
|
8
|
+
- "bisslog_flask/**"
|
9
|
+
- "pyproject.toml"
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
run-changes-reception:
|
13
|
+
uses: darwinhc/bisslog-flask/.github/workflows/receive-changes.yml@master
|
14
|
+
|
15
|
+
determine-version:
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
outputs:
|
18
|
+
version: ${{ steps.set-version.outputs.VERSION }}
|
19
|
+
steps:
|
20
|
+
- name: Checkout repository
|
21
|
+
uses: actions/checkout@v4
|
22
|
+
with:
|
23
|
+
fetch-depth: 0
|
24
|
+
|
25
|
+
- name: Install dependencies
|
26
|
+
run: |
|
27
|
+
python -m pip install --upgrade pip
|
28
|
+
pip install setuptools_scm
|
29
|
+
|
30
|
+
- name: Determine version for TestPyPI
|
31
|
+
id: set-version
|
32
|
+
run: |
|
33
|
+
VERSION=$(python -c "import setuptools_scm; print(setuptools_scm.get_version(version_scheme='post-release', local_scheme='no-local-version'))")
|
34
|
+
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
35
|
+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
36
|
+
|
37
|
+
deploy:
|
38
|
+
runs-on: ubuntu-latest
|
39
|
+
needs: [run-changes-reception, determine-version]
|
40
|
+
|
41
|
+
steps:
|
42
|
+
- name: Checkout code
|
43
|
+
uses: actions/checkout@v4
|
44
|
+
with:
|
45
|
+
fetch-depth: 0
|
46
|
+
|
47
|
+
- name: Set up Python
|
48
|
+
uses: actions/setup-python@v4
|
49
|
+
with:
|
50
|
+
python-version: "3.x"
|
51
|
+
|
52
|
+
- name: Install dependencies
|
53
|
+
run: |
|
54
|
+
python -m pip install --upgrade pip
|
55
|
+
pip install build twine setuptools_scm
|
56
|
+
- name: Printing version to build
|
57
|
+
run: echo ${{ needs.determine-version.outputs.version }}
|
58
|
+
|
59
|
+
- name: Build package with correct version
|
60
|
+
run: |
|
61
|
+
python -m build
|
62
|
+
env:
|
63
|
+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.determine-version.outputs.version }}
|
64
|
+
|
65
|
+
- name: Publish to TestPyPI
|
66
|
+
env:
|
67
|
+
TWINE_USERNAME: __token__
|
68
|
+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
69
|
+
run: twine upload --skip-existing --verbose --repository testpypi dist/*
|
70
|
+
|
71
|
+
- name: Install from TestPyPI to verify
|
72
|
+
run: |
|
73
|
+
python -m venv test_env
|
74
|
+
source test_env/bin/activate
|
75
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps bisslog_flask==${{ needs.determine-version.outputs.version }}
|
76
|
+
deactivate
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Analyze new changes
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- 'feature/**'
|
7
|
+
- 'fix/**'
|
8
|
+
- 'hotfix/**'
|
9
|
+
workflow_dispatch:
|
10
|
+
workflow_call:
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
run-tests:
|
14
|
+
uses: darwinhc/bisslog-core-py/.github/workflows/pytest.yml@master
|
15
|
+
with:
|
16
|
+
coverage_threshold: ${{ vars.TEST_COVERAGE_THRESHOLD }}
|
17
|
+
target_folder: "bisslog_flask"
|
18
|
+
|
19
|
+
run-linter:
|
20
|
+
uses: darwinhc/bisslog-core-py/.github/workflows/pylint.yml@master
|
21
|
+
with:
|
22
|
+
pylint_threshold: ${{ vars.PYLINT_THRESHOLD }}
|
23
|
+
target_folder: "bisslog_flask"
|
24
|
+
|
25
|
+
run-complexity:
|
26
|
+
uses: darwinhc/bisslog-core-py/.github/workflows/radon.yml@master
|
27
|
+
with:
|
28
|
+
radon_threshold: ${{ vars.RADON_THRESHOLD }}
|
29
|
+
target_folder: "bisslog_flask"
|
@@ -0,0 +1,175 @@
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
2
|
+
__pycache__/
|
3
|
+
*.py[cod]
|
4
|
+
*$py.class
|
5
|
+
|
6
|
+
# C extensions
|
7
|
+
*.so
|
8
|
+
|
9
|
+
# Distribution / packaging
|
10
|
+
.Python
|
11
|
+
build/
|
12
|
+
develop-eggs/
|
13
|
+
.todo/
|
14
|
+
dist/
|
15
|
+
downloads/
|
16
|
+
eggs/
|
17
|
+
.eggs/
|
18
|
+
lib/
|
19
|
+
lib64/
|
20
|
+
parts/
|
21
|
+
sdist/
|
22
|
+
var/
|
23
|
+
wheels/
|
24
|
+
share/python-wheels/
|
25
|
+
*.egg-info/
|
26
|
+
.installed.cfg
|
27
|
+
*.egg
|
28
|
+
MANIFEST
|
29
|
+
|
30
|
+
# PyInstaller
|
31
|
+
# Usually these files are written by a python script from a template
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33
|
+
*.manifest
|
34
|
+
*.spec
|
35
|
+
|
36
|
+
# Installer logs
|
37
|
+
pip-log.txt
|
38
|
+
pip-delete-this-directory.txt
|
39
|
+
|
40
|
+
# Unit test / coverage reports
|
41
|
+
htmlcov/
|
42
|
+
.tox/
|
43
|
+
.nox/
|
44
|
+
.coverage
|
45
|
+
.coverage.*
|
46
|
+
.cache
|
47
|
+
nosetests.xml
|
48
|
+
coverage.xml
|
49
|
+
*.cover
|
50
|
+
*.py,cover
|
51
|
+
.hypothesis/
|
52
|
+
.pytest_cache/
|
53
|
+
cover/
|
54
|
+
|
55
|
+
# Translations
|
56
|
+
*.mo
|
57
|
+
*.pot
|
58
|
+
|
59
|
+
# Django stuff:
|
60
|
+
*.log
|
61
|
+
local_settings.py
|
62
|
+
db.sqlite3
|
63
|
+
db.sqlite3-journal
|
64
|
+
|
65
|
+
# Flask stuff:
|
66
|
+
instance/
|
67
|
+
.webassets-cache
|
68
|
+
|
69
|
+
# Scrapy stuff:
|
70
|
+
.scrapy
|
71
|
+
|
72
|
+
# Sphinx documentation
|
73
|
+
docs/_build/
|
74
|
+
|
75
|
+
# PyBuilder
|
76
|
+
.pybuilder/
|
77
|
+
target/
|
78
|
+
|
79
|
+
# Jupyter Notebook
|
80
|
+
.ipynb_checkpoints
|
81
|
+
|
82
|
+
# IPython
|
83
|
+
profile_default/
|
84
|
+
ipython_config.py
|
85
|
+
|
86
|
+
# pyenv
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
89
|
+
# .python-version
|
90
|
+
|
91
|
+
# pipenv
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
95
|
+
# install all needed dependencies.
|
96
|
+
#Pipfile.lock
|
97
|
+
|
98
|
+
# UV
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
101
|
+
# commonly ignored for libraries.
|
102
|
+
#uv.lock
|
103
|
+
|
104
|
+
# poetry
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
107
|
+
# commonly ignored for libraries.
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
109
|
+
#poetry.lock
|
110
|
+
|
111
|
+
# pdm
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
113
|
+
#pdm.lock
|
114
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
115
|
+
# in version control.
|
116
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
117
|
+
.pdm.toml
|
118
|
+
.pdm-python
|
119
|
+
.pdm-build/
|
120
|
+
|
121
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
122
|
+
__pypackages__/
|
123
|
+
|
124
|
+
# Celery stuff
|
125
|
+
celerybeat-schedule
|
126
|
+
celerybeat.pid
|
127
|
+
|
128
|
+
# SageMath parsed files
|
129
|
+
*.sage.py
|
130
|
+
|
131
|
+
# Environments
|
132
|
+
.env
|
133
|
+
.venv
|
134
|
+
env/
|
135
|
+
venv/
|
136
|
+
ENV/
|
137
|
+
env.bak/
|
138
|
+
venv.bak/
|
139
|
+
|
140
|
+
# Spyder project settings
|
141
|
+
.spyderproject
|
142
|
+
.spyproject
|
143
|
+
|
144
|
+
# Rope project settings
|
145
|
+
.ropeproject
|
146
|
+
|
147
|
+
# mkdocs documentation
|
148
|
+
/site
|
149
|
+
|
150
|
+
# mypy
|
151
|
+
.mypy_cache/
|
152
|
+
.dmypy.json
|
153
|
+
dmypy.json
|
154
|
+
|
155
|
+
# Pyre type checker
|
156
|
+
.pyre/
|
157
|
+
|
158
|
+
# pytype static type analyzer
|
159
|
+
.pytype/
|
160
|
+
|
161
|
+
# Cython debug symbols
|
162
|
+
cython_debug/
|
163
|
+
|
164
|
+
# PyCharm
|
165
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
166
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
167
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
168
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
169
|
+
.idea/
|
170
|
+
|
171
|
+
# Ruff stuff:
|
172
|
+
.ruff_cache/
|
173
|
+
|
174
|
+
# PyPI configuration file
|
175
|
+
.pypirc
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Darwin Herrera C.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,141 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: bisslog_flask
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: It is an extension of the bisslog library to support processes with flask
|
5
|
+
Author-email: Darwin Stiven Herrera Cartagena <darwinsherrerac@gmail.com>
|
6
|
+
Project-URL: Homepage, https://github.com/darwinhc/bisslog-flask
|
7
|
+
Keywords: hexagonal,adapters,bisslog,flask
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.7
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
License-File: LICENSE
|
13
|
+
Requires-Dist: bisslog>=0.0.7
|
14
|
+
Requires-Dist: bisslog-schema>=0.0.3
|
15
|
+
Requires-Dist: flask
|
16
|
+
Provides-Extra: websocket
|
17
|
+
Requires-Dist: flask-socketio; extra == "websocket"
|
18
|
+
Provides-Extra: cors
|
19
|
+
Requires-Dist: flask-cors>=6.0.0; extra == "cors"
|
20
|
+
Dynamic: license-file
|
21
|
+
|
22
|
+
|
23
|
+
# bisslog-flask
|
24
|
+
|
25
|
+
[](https://pypi.org/project/bisslog-flask/)
|
26
|
+
[](LICENSE)
|
27
|
+
|
28
|
+
**bisslog-flask** is an extension of the bisslog library to support processes with Flask. It enables dynamic HTTP and WebSocket route registration from use case metadata, allowing developers to build clean, modular, and metadata-driven APIs with minimal boilerplate.
|
29
|
+
|
30
|
+
Part of the bisslog ecosystem, it is designed to work seamlessly with domain-centric architectures like Hexagonal or Clean Architecture.
|
31
|
+
|
32
|
+
## Features
|
33
|
+
|
34
|
+
- ๐ Dynamic route registration for HTTP and WebSocket triggers
|
35
|
+
|
36
|
+
- ๐ง Metadata-driven setup โ use YAML or JSON to declare your use cases
|
37
|
+
|
38
|
+
- ๐ Automatic CORS per endpoint using flask-cors
|
39
|
+
|
40
|
+
- ๐ Extensible resolver pattern โ plug in your own processor
|
41
|
+
|
42
|
+
- โ๏ธ Mapper integration โ maps HTTP request parts to domain function arguments
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
## ๐ฆ Installation
|
47
|
+
|
48
|
+
~~~shell
|
49
|
+
pip install bisslog-flask
|
50
|
+
~~~
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
## ๐ Quickstart
|
56
|
+
|
57
|
+
### Programmatically
|
58
|
+
|
59
|
+
if you want to configure the app before bisslog touches it
|
60
|
+
~~~python
|
61
|
+
from flask import Flask
|
62
|
+
from bisslog_flask import BisslogFlask
|
63
|
+
|
64
|
+
app = Flask(__name__)
|
65
|
+
BisslogFlask(
|
66
|
+
metadata_file="metadata.yml",
|
67
|
+
use_cases_folder_path="src/domain/use_cases",
|
68
|
+
app=app
|
69
|
+
)
|
70
|
+
|
71
|
+
if __name__ == "__main__":
|
72
|
+
app.run(debug=True)
|
73
|
+
~~~
|
74
|
+
|
75
|
+
or
|
76
|
+
|
77
|
+
~~~python
|
78
|
+
from bisslog_flask import BisslogFlask
|
79
|
+
|
80
|
+
app = BisslogFlask(
|
81
|
+
metadata_file="metadata.yml",
|
82
|
+
use_cases_folder_path="src/domain/use_cases"
|
83
|
+
)
|
84
|
+
|
85
|
+
if __name__ == "__main__":
|
86
|
+
app.run(debug=True)
|
87
|
+
~~~
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
## ๐ง How It Works
|
92
|
+
|
93
|
+
1. Loads metadata and discovers use case functions (or callables), then uses resolvers to register routes dynamically into a Flask app.
|
94
|
+
|
95
|
+
|
96
|
+
## ๐ CORS Handling
|
97
|
+
|
98
|
+
CORS is applied only when allow_cors: true is specified in the trigger
|
99
|
+
|
100
|
+
Fully dynamic: works even with dynamic Flask routes like /users/<id>
|
101
|
+
|
102
|
+
Powered by `@cross_origin` from `flask-cors`
|
103
|
+
|
104
|
+
|
105
|
+
## โ
Requirements
|
106
|
+
|
107
|
+
Python โฅ 3.7
|
108
|
+
|
109
|
+
Flask โฅ 2.0
|
110
|
+
|
111
|
+
bisslog-schema โฅ 0.0.3
|
112
|
+
|
113
|
+
flask-cors
|
114
|
+
|
115
|
+
(Optional) flask-socketio if using WebSocket triggers
|
116
|
+
|
117
|
+
|
118
|
+
## ๐งช Testing Tip
|
119
|
+
|
120
|
+
You can test the generated Flask app directly with `app.test_client()` if you take the programmatic way:
|
121
|
+
|
122
|
+
```python
|
123
|
+
from bisslog_flask import BisslogFlask
|
124
|
+
|
125
|
+
def test_user_create():
|
126
|
+
app = BisslogFlask(metadata_file="metadata.yml", use_cases_folder_path="src/use_cases")
|
127
|
+
client = app.test_client()
|
128
|
+
response = client.post("/user", json={"name": "Ana", "email": "ana@example.com"})
|
129
|
+
assert response.status_code == 200
|
130
|
+
```
|
131
|
+
|
132
|
+
Not generating code or using the programmatic way you just need to test your use cases.
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
## ๐ License
|
137
|
+
|
138
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
139
|
+
|
140
|
+
|
141
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
# bisslog-flask
|
3
|
+
|
4
|
+
[](https://pypi.org/project/bisslog-flask/)
|
5
|
+
[](LICENSE)
|
6
|
+
|
7
|
+
**bisslog-flask** is an extension of the bisslog library to support processes with Flask. It enables dynamic HTTP and WebSocket route registration from use case metadata, allowing developers to build clean, modular, and metadata-driven APIs with minimal boilerplate.
|
8
|
+
|
9
|
+
Part of the bisslog ecosystem, it is designed to work seamlessly with domain-centric architectures like Hexagonal or Clean Architecture.
|
10
|
+
|
11
|
+
## Features
|
12
|
+
|
13
|
+
- ๐ Dynamic route registration for HTTP and WebSocket triggers
|
14
|
+
|
15
|
+
- ๐ง Metadata-driven setup โ use YAML or JSON to declare your use cases
|
16
|
+
|
17
|
+
- ๐ Automatic CORS per endpoint using flask-cors
|
18
|
+
|
19
|
+
- ๐ Extensible resolver pattern โ plug in your own processor
|
20
|
+
|
21
|
+
- โ๏ธ Mapper integration โ maps HTTP request parts to domain function arguments
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## ๐ฆ Installation
|
26
|
+
|
27
|
+
~~~shell
|
28
|
+
pip install bisslog-flask
|
29
|
+
~~~
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
## ๐ Quickstart
|
35
|
+
|
36
|
+
### Programmatically
|
37
|
+
|
38
|
+
if you want to configure the app before bisslog touches it
|
39
|
+
~~~python
|
40
|
+
from flask import Flask
|
41
|
+
from bisslog_flask import BisslogFlask
|
42
|
+
|
43
|
+
app = Flask(__name__)
|
44
|
+
BisslogFlask(
|
45
|
+
metadata_file="metadata.yml",
|
46
|
+
use_cases_folder_path="src/domain/use_cases",
|
47
|
+
app=app
|
48
|
+
)
|
49
|
+
|
50
|
+
if __name__ == "__main__":
|
51
|
+
app.run(debug=True)
|
52
|
+
~~~
|
53
|
+
|
54
|
+
or
|
55
|
+
|
56
|
+
~~~python
|
57
|
+
from bisslog_flask import BisslogFlask
|
58
|
+
|
59
|
+
app = BisslogFlask(
|
60
|
+
metadata_file="metadata.yml",
|
61
|
+
use_cases_folder_path="src/domain/use_cases"
|
62
|
+
)
|
63
|
+
|
64
|
+
if __name__ == "__main__":
|
65
|
+
app.run(debug=True)
|
66
|
+
~~~
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## ๐ง How It Works
|
71
|
+
|
72
|
+
1. Loads metadata and discovers use case functions (or callables), then uses resolvers to register routes dynamically into a Flask app.
|
73
|
+
|
74
|
+
|
75
|
+
## ๐ CORS Handling
|
76
|
+
|
77
|
+
CORS is applied only when allow_cors: true is specified in the trigger
|
78
|
+
|
79
|
+
Fully dynamic: works even with dynamic Flask routes like /users/<id>
|
80
|
+
|
81
|
+
Powered by `@cross_origin` from `flask-cors`
|
82
|
+
|
83
|
+
|
84
|
+
## โ
Requirements
|
85
|
+
|
86
|
+
Python โฅ 3.7
|
87
|
+
|
88
|
+
Flask โฅ 2.0
|
89
|
+
|
90
|
+
bisslog-schema โฅ 0.0.3
|
91
|
+
|
92
|
+
flask-cors
|
93
|
+
|
94
|
+
(Optional) flask-socketio if using WebSocket triggers
|
95
|
+
|
96
|
+
|
97
|
+
## ๐งช Testing Tip
|
98
|
+
|
99
|
+
You can test the generated Flask app directly with `app.test_client()` if you take the programmatic way:
|
100
|
+
|
101
|
+
```python
|
102
|
+
from bisslog_flask import BisslogFlask
|
103
|
+
|
104
|
+
def test_user_create():
|
105
|
+
app = BisslogFlask(metadata_file="metadata.yml", use_cases_folder_path="src/use_cases")
|
106
|
+
client = app.test_client()
|
107
|
+
response = client.post("/user", json={"name": "Ana", "email": "ana@example.com"})
|
108
|
+
assert response.status_code == 200
|
109
|
+
```
|
110
|
+
|
111
|
+
Not generating code or using the programmatic way you just need to test your use cases.
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
## ๐ License
|
116
|
+
|
117
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
118
|
+
|
119
|
+
|
120
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"""
|
2
|
+
bisslog_flask
|
3
|
+
|
4
|
+
An extension of the `bisslog` library to support service orchestration via Flask.
|
5
|
+
|
6
|
+
This package enables dynamic registration of HTTP and WebSocket routes in a Flask
|
7
|
+
application, using declarative metadata (YAML/JSON). It promotes clean separation
|
8
|
+
between application logic and infrastructure concerns, aligning with hexagonal
|
9
|
+
or clean architecture principles.
|
10
|
+
|
11
|
+
|
12
|
+
Requirements
|
13
|
+
------------
|
14
|
+
- Flask >= 2.0
|
15
|
+
- bisslog-schema >= 0.0.3
|
16
|
+
- flask-cors
|
17
|
+
- (optional) flask-socketio for WebSocket integration
|
18
|
+
|
19
|
+
License
|
20
|
+
-------
|
21
|
+
MIT ยฉ Darwin Stiven Herrera Cartagena
|
22
|
+
"""
|
23
|
+
from .initializer.init_flask_app_manager import BisslogFlask
|
24
|
+
from .socket_helper.socket_helper import BisslogFlaskSocketHelper
|
25
|
+
|
26
|
+
__all__ = ["BisslogFlask", "BisslogFlaskSocketHelper"]
|
File without changes
|