lightapi 0.1.0__tar.gz → 0.1.2__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.
- lightapi-0.1.2/.github/workflows/pages-publish.yml +59 -0
- lightapi-0.1.2/.github/workflows/python-publish.yml +129 -0
- lightapi-0.1.2/.github/workflows/test-dev.yml +86 -0
- lightapi-0.1.2/.gitignore +110 -0
- lightapi-0.1.2/.idx/dev.nix +38 -0
- lightapi-0.1.2/LICENSE +21 -0
- lightapi-0.1.2/PKG-INFO +207 -0
- lightapi-0.1.2/README.md +156 -0
- lightapi-0.1.2/docs/.pages +25 -0
- lightapi-0.1.2/docs/advanced/.pages +9 -0
- lightapi-0.1.2/docs/advanced/authentication.md +734 -0
- lightapi-0.1.2/docs/advanced/caching.md +292 -0
- lightapi-0.1.2/docs/advanced/filtering.md +53 -0
- lightapi-0.1.2/docs/advanced/middleware.md +244 -0
- lightapi-0.1.2/docs/advanced/pagination.md +66 -0
- lightapi-0.1.2/docs/advanced/validation.md +52 -0
- lightapi-0.1.2/docs/api-reference/.pages +12 -0
- lightapi-0.1.2/docs/api-reference/auth.md +569 -0
- lightapi-0.1.2/docs/api-reference/cache.md +167 -0
- lightapi-0.1.2/docs/api-reference/core.md +459 -0
- lightapi-0.1.2/docs/api-reference/database.md +150 -0
- lightapi-0.1.2/docs/api-reference/exceptions.md +197 -0
- lightapi-0.1.2/docs/api-reference/filters.md +698 -0
- lightapi-0.1.2/docs/api-reference/index.md +57 -0
- lightapi-0.1.2/docs/api-reference/models.md +196 -0
- lightapi-0.1.2/docs/api-reference/pagination.md +172 -0
- lightapi-0.1.2/docs/api-reference/rest.md +750 -0
- lightapi-0.1.2/docs/api-reference/swagger.md +225 -0
- lightapi-0.1.2/docs/api-reference/validation.md +226 -0
- lightapi-0.1.2/docs/deployment/.pages +6 -0
- lightapi-0.1.2/docs/deployment/docker.md +50 -0
- lightapi-0.1.2/docs/deployment/production.md +70 -0
- lightapi-0.1.2/docs/deployment/security.md +58 -0
- lightapi-0.1.2/docs/examples/.pages +12 -0
- lightapi-0.1.2/docs/examples/auth.md +486 -0
- lightapi-0.1.2/docs/examples/basic-crud.md +108 -0
- lightapi-0.1.2/docs/examples/basic-rest.md +302 -0
- lightapi-0.1.2/docs/examples/caching.md +665 -0
- lightapi-0.1.2/docs/examples/custom-application.md +81 -0
- lightapi-0.1.2/docs/examples/filtering-pagination.md +408 -0
- lightapi-0.1.2/docs/examples/middleware.md +705 -0
- lightapi-0.1.2/docs/examples/validation.md +634 -0
- lightapi-0.1.2/docs/getting-started/.pages +15 -0
- lightapi-0.1.2/docs/getting-started/configuration.md +43 -0
- lightapi-0.1.2/docs/getting-started/first-steps.md +88 -0
- lightapi-0.1.2/docs/getting-started/installation.md +12 -0
- lightapi-0.1.2/docs/getting-started/introduction.md +35 -0
- lightapi-0.1.2/docs/getting-started/quickstart.md +47 -0
- lightapi-0.1.2/docs/index.md +154 -0
- lightapi-0.1.2/docs/technical-reference/.pages +9 -0
- lightapi-0.1.2/docs/technical-reference/cache.md +31 -0
- lightapi-0.1.2/docs/technical-reference/core-api.md +71 -0
- lightapi-0.1.2/docs/technical-reference/endpoints.md +77 -0
- lightapi-0.1.2/docs/technical-reference/handlers.md +69 -0
- lightapi-0.1.2/docs/technical-reference/middleware.md +51 -0
- lightapi-0.1.2/docs/technical-reference/models.md +31 -0
- lightapi-0.1.2/docs/troubleshooting.md +354 -0
- lightapi-0.1.2/docs/tutorial/.pages +8 -0
- lightapi-0.1.2/docs/tutorial/basic-api.md +58 -0
- lightapi-0.1.2/docs/tutorial/database.md +90 -0
- lightapi-0.1.2/docs/tutorial/endpoints.md +67 -0
- lightapi-0.1.2/docs/tutorial/requests.md +69 -0
- lightapi-0.1.2/docs/tutorial/responses.md +93 -0
- lightapi-0.1.2/examples/README.md +206 -0
- lightapi-0.1.2/examples/auth_example.py +147 -0
- lightapi-0.1.2/examples/basic_rest_api.py +42 -0
- lightapi-0.1.2/examples/caching_example.py +189 -0
- lightapi-0.1.2/examples/custom_snippet.py +127 -0
- lightapi-0.1.2/examples/example.py +125 -0
- lightapi-0.1.2/examples/filtering_pagination_example.py +366 -0
- lightapi-0.1.2/examples/middleware_example.py +222 -0
- lightapi-0.1.2/examples/relationships_example.py +475 -0
- lightapi-0.1.2/examples/swagger_example.py +280 -0
- lightapi-0.1.2/examples/user_goal_example.py +148 -0
- lightapi-0.1.2/examples/validation_example.py +96 -0
- lightapi-0.1.2/lightapi/__init__.py +30 -0
- lightapi-0.1.2/lightapi/auth.py +125 -0
- lightapi-0.1.2/lightapi/base_endpoint.py +248 -0
- lightapi-0.1.2/lightapi/cache.py +108 -0
- lightapi-0.1.2/lightapi/config.py +71 -0
- lightapi-0.1.2/lightapi/core.py +665 -0
- lightapi-0.1.2/lightapi/database.py +62 -0
- lightapi-0.1.2/lightapi/exceptions.py +24 -0
- lightapi-0.1.2/lightapi/filters.py +58 -0
- lightapi-0.1.2/lightapi/handlers.py +357 -0
- lightapi-0.1.2/lightapi/lightapi.py +110 -0
- lightapi-0.1.2/lightapi/models.py +136 -0
- lightapi-0.1.2/lightapi/pagination.py +78 -0
- lightapi-0.1.2/lightapi/rest.py +395 -0
- lightapi-0.1.2/lightapi/swagger.py +324 -0
- lightapi-0.1.2/mkdocs.yml +148 -0
- lightapi-0.1.2/pyproject.toml +114 -0
- lightapi-0.1.2/pytest.ini +4 -0
- lightapi-0.1.2/requirements.txt +8 -0
- lightapi-0.1.2/test_simple_response.py +16 -0
- lightapi-0.1.2/tests/__init__.py +0 -0
- lightapi-0.1.2/tests/conftest.py +70 -0
- lightapi-0.1.2/tests/test_additional_features.py +127 -0
- lightapi-0.1.2/tests/test_auth.py +87 -0
- lightapi-0.1.2/tests/test_auth_example.py +301 -0
- lightapi-0.1.2/tests/test_basic_rest_api.py +234 -0
- lightapi-0.1.2/tests/test_cache.py +83 -0
- lightapi-0.1.2/tests/test_caching_example.py +418 -0
- lightapi-0.1.2/tests/test_clients.py +0 -0
- lightapi-0.1.2/tests/test_core.py +81 -0
- lightapi-0.1.2/tests/test_custom_snippet.py +328 -0
- lightapi-0.1.2/tests/test_example.py +56 -0
- lightapi-0.1.2/tests/test_filtering_pagination_example.py +476 -0
- lightapi-0.1.2/tests/test_filters.py +57 -0
- lightapi-0.1.2/tests/test_helpers.py +82 -0
- lightapi-0.1.2/tests/test_integration.py +112 -0
- lightapi-0.1.2/tests/test_middleware.py +92 -0
- lightapi-0.1.2/tests/test_middleware_example.py +356 -0
- lightapi-0.1.2/tests/test_pagination.py +91 -0
- lightapi-0.1.2/tests/test_rest.py +170 -0
- lightapi-0.1.2/tests/test_swagger.py +111 -0
- lightapi-0.1.2/tests/test_validation_example.py +210 -0
- lightapi-0.1.2/update_version.py +36 -0
- lightapi-0.1.2/uv.lock +734 -0
- lightapi-0.1.0/PKG-INFO +0 -65
- lightapi-0.1.0/README.md +0 -52
- lightapi-0.1.0/pyproject.toml +0 -15
- lightapi-0.1.0/setup.py +0 -30
- {lightapi-0.1.0/src/lightapi → lightapi-0.1.2/examples}/__init__.py +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Deploy GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
pages: write
|
|
11
|
+
id-token: write
|
|
12
|
+
pull-requests: read
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: "pages"
|
|
16
|
+
cancel-in-progress: false
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
deploy:
|
|
20
|
+
environment:
|
|
21
|
+
name: github-pages
|
|
22
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout
|
|
26
|
+
uses: actions/checkout@v4
|
|
27
|
+
with:
|
|
28
|
+
fetch-depth: 0
|
|
29
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
30
|
+
|
|
31
|
+
- name: Set up Python
|
|
32
|
+
uses: actions/setup-python@v4
|
|
33
|
+
with:
|
|
34
|
+
python-version: '3.x'
|
|
35
|
+
cache: 'pip'
|
|
36
|
+
|
|
37
|
+
- name: Install dependencies
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
pip install mkdocs mkdocs-material mkdocs-git-authors-plugin mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin mkdocs-awesome-pages-plugin mkdocs-glightbox mkdocstrings[python]
|
|
41
|
+
pip install -e .[docs]
|
|
42
|
+
|
|
43
|
+
- name: Build site with MkDocs
|
|
44
|
+
env:
|
|
45
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
46
|
+
run: |
|
|
47
|
+
mkdocs build --strict
|
|
48
|
+
|
|
49
|
+
- name: Setup Pages
|
|
50
|
+
uses: actions/configure-pages@v5
|
|
51
|
+
|
|
52
|
+
- name: Upload artifact
|
|
53
|
+
uses: actions/upload-pages-artifact@v3
|
|
54
|
+
with:
|
|
55
|
+
path: './site'
|
|
56
|
+
|
|
57
|
+
- name: Deploy to GitHub Pages
|
|
58
|
+
id: deployment
|
|
59
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when code is pushed to main
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
branches: [ "master" ]
|
|
14
|
+
release:
|
|
15
|
+
types: [published]
|
|
16
|
+
|
|
17
|
+
permissions:
|
|
18
|
+
contents: write
|
|
19
|
+
id-token: write
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
test:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
|
27
|
+
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
+
uses: actions/setup-python@v4
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
|
|
35
|
+
- name: Install dependencies
|
|
36
|
+
run: |
|
|
37
|
+
python -m pip install --upgrade pip
|
|
38
|
+
pip install -e .[test,dev]
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: |
|
|
42
|
+
pytest tests/ -v
|
|
43
|
+
|
|
44
|
+
deploy:
|
|
45
|
+
needs: test
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
if: github.ref == 'refs/heads/master'
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@v4
|
|
51
|
+
with:
|
|
52
|
+
fetch-depth: 0
|
|
53
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
54
|
+
|
|
55
|
+
- name: Set up Python
|
|
56
|
+
uses: actions/setup-python@v4
|
|
57
|
+
with:
|
|
58
|
+
python-version: '3.11'
|
|
59
|
+
|
|
60
|
+
- name: Install dependencies
|
|
61
|
+
run: |
|
|
62
|
+
python -m pip install --upgrade pip
|
|
63
|
+
pip install build twine tomli-w tomli
|
|
64
|
+
|
|
65
|
+
- name: Create version update script
|
|
66
|
+
run: |
|
|
67
|
+
cat > update_version.py << 'EOF'
|
|
68
|
+
import sys
|
|
69
|
+
import os
|
|
70
|
+
try:
|
|
71
|
+
import tomllib
|
|
72
|
+
except ImportError:
|
|
73
|
+
import tomli as tomllib
|
|
74
|
+
import tomli_w
|
|
75
|
+
|
|
76
|
+
def get_current_version():
|
|
77
|
+
with open('pyproject.toml', 'rb') as f:
|
|
78
|
+
data = tomllib.load(f)
|
|
79
|
+
return data['project']['version']
|
|
80
|
+
|
|
81
|
+
def increment_version(version):
|
|
82
|
+
parts = version.split('.')
|
|
83
|
+
parts[-1] = str(int(parts[-1]) + 1)
|
|
84
|
+
return '.'.join(parts)
|
|
85
|
+
|
|
86
|
+
def update_version(new_version):
|
|
87
|
+
with open('pyproject.toml', 'rb') as f:
|
|
88
|
+
data = tomllib.load(f)
|
|
89
|
+
|
|
90
|
+
data['project']['version'] = new_version
|
|
91
|
+
|
|
92
|
+
with open('pyproject.toml', 'wb') as f:
|
|
93
|
+
tomli_w.dump(data, f)
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
current = get_current_version()
|
|
97
|
+
new = increment_version(current)
|
|
98
|
+
update_version(new)
|
|
99
|
+
print(f"Updated version from {current} to {new}")
|
|
100
|
+
|
|
101
|
+
# Write to GitHub output
|
|
102
|
+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
|
|
103
|
+
f.write(f"new_version={new}\n")
|
|
104
|
+
EOF
|
|
105
|
+
|
|
106
|
+
- name: Update version
|
|
107
|
+
id: update_version
|
|
108
|
+
run: python update_version.py
|
|
109
|
+
|
|
110
|
+
- name: Build package
|
|
111
|
+
run: python -m build
|
|
112
|
+
|
|
113
|
+
- name: Check package
|
|
114
|
+
run: twine check dist/*
|
|
115
|
+
|
|
116
|
+
- name: Publish package to PyPI
|
|
117
|
+
env:
|
|
118
|
+
TWINE_USERNAME: __token__
|
|
119
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
120
|
+
run: |
|
|
121
|
+
twine upload dist/*
|
|
122
|
+
|
|
123
|
+
- name: Commit version update
|
|
124
|
+
run: |
|
|
125
|
+
git config --local user.email "action@github.com"
|
|
126
|
+
git config --local user.name "GitHub Action"
|
|
127
|
+
git add pyproject.toml
|
|
128
|
+
git commit -m "Bump version to ${{ steps.update_version.outputs.new_version }}" || exit 0
|
|
129
|
+
git push
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# This workflow runs tests on the development branch
|
|
2
|
+
# It runs tests but does not publish to PyPI
|
|
3
|
+
|
|
4
|
+
name: Development Tests
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "development" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "development", "master" ]
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
test:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
26
|
+
uses: actions/setup-python@v4
|
|
27
|
+
with:
|
|
28
|
+
python-version: ${{ matrix.python-version }}
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
pip install -e .[test,dev]
|
|
34
|
+
|
|
35
|
+
- name: Run linting (Python 3.11 only)
|
|
36
|
+
if: matrix.python-version == '3.11'
|
|
37
|
+
run: |
|
|
38
|
+
# Install linting tools
|
|
39
|
+
pip install black isort flake8 mypy
|
|
40
|
+
|
|
41
|
+
# Run code formatting checks (warn only in development)
|
|
42
|
+
echo "🔍 Checking code formatting..."
|
|
43
|
+
black --check --diff . || echo "⚠️ Code formatting issues found, but not failing in development"
|
|
44
|
+
|
|
45
|
+
# Run import sorting checks (warn only in development)
|
|
46
|
+
echo "🔍 Checking import sorting..."
|
|
47
|
+
isort --check-only --diff . || echo "⚠️ Import sorting issues found, but not failing in development"
|
|
48
|
+
|
|
49
|
+
# Run style checks (errors only)
|
|
50
|
+
echo "🔍 Checking critical style issues..."
|
|
51
|
+
flake8 lightapi/ --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
52
|
+
|
|
53
|
+
# Run additional style checks (warnings only)
|
|
54
|
+
echo "🔍 Checking style guidelines..."
|
|
55
|
+
flake8 lightapi/ --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
|
|
56
|
+
|
|
57
|
+
- name: Run tests
|
|
58
|
+
run: |
|
|
59
|
+
pytest tests/ -v --tb=short
|
|
60
|
+
|
|
61
|
+
- name: Test package build
|
|
62
|
+
if: matrix.python-version == '3.11'
|
|
63
|
+
run: |
|
|
64
|
+
pip install build
|
|
65
|
+
python -m build
|
|
66
|
+
|
|
67
|
+
- name: Check package
|
|
68
|
+
if: matrix.python-version == '3.11'
|
|
69
|
+
run: |
|
|
70
|
+
pip install twine
|
|
71
|
+
twine check dist/*
|
|
72
|
+
|
|
73
|
+
# Job to check if all tests passed
|
|
74
|
+
test-summary:
|
|
75
|
+
needs: test
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
if: always()
|
|
78
|
+
steps:
|
|
79
|
+
- name: Check test results
|
|
80
|
+
run: |
|
|
81
|
+
if [ "${{ needs.test.result }}" = "success" ]; then
|
|
82
|
+
echo "✅ All tests passed! Ready for merge to master."
|
|
83
|
+
else
|
|
84
|
+
echo "❌ Tests failed. Please fix issues before merging."
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
.idea/**/workspace.xml
|
|
2
|
+
.idea/**/tasks.xml
|
|
3
|
+
.idea/**/usage.statistics.xml
|
|
4
|
+
.idea/**/dictionaries
|
|
5
|
+
.idea/**/shelf
|
|
6
|
+
.idea/**/aws.xml
|
|
7
|
+
.idea/**/contentModel.xml
|
|
8
|
+
.idea/**/dataSources/
|
|
9
|
+
.idea/**/dataSources.ids
|
|
10
|
+
.idea/**/dataSources.local.xml
|
|
11
|
+
.idea/**/sqlDataSources.xml
|
|
12
|
+
.idea/**/dynamic.xml
|
|
13
|
+
.idea/**/uiDesigner.xml
|
|
14
|
+
.idea/**/dbnavigator.xml
|
|
15
|
+
.idea/**/gradle.xml
|
|
16
|
+
.idea/**/libraries
|
|
17
|
+
cmake-build-*/
|
|
18
|
+
.idea/**/mongoSettings.xml
|
|
19
|
+
*.iws
|
|
20
|
+
out/
|
|
21
|
+
.idea_modules/
|
|
22
|
+
atlassian-ide-plugin.xml
|
|
23
|
+
.idea/replstate.xml
|
|
24
|
+
.idea/sonarlint/
|
|
25
|
+
com_crashlytics_export_strings.xml
|
|
26
|
+
crashlytics.properties
|
|
27
|
+
crashlytics-build.properties
|
|
28
|
+
fabric.properties
|
|
29
|
+
.idea/httpRequests
|
|
30
|
+
.idea/caches/build_file_checksums.ser
|
|
31
|
+
__pycache__/
|
|
32
|
+
*.py[cod]
|
|
33
|
+
*$py.class
|
|
34
|
+
*.so
|
|
35
|
+
.Python
|
|
36
|
+
build/
|
|
37
|
+
develop-eggs/
|
|
38
|
+
dist/
|
|
39
|
+
downloads/
|
|
40
|
+
eggs/
|
|
41
|
+
.eggs/
|
|
42
|
+
lib/
|
|
43
|
+
lib64/
|
|
44
|
+
parts/
|
|
45
|
+
sdist/
|
|
46
|
+
var/
|
|
47
|
+
wheels/
|
|
48
|
+
share/python-wheels/
|
|
49
|
+
*.egg-info/
|
|
50
|
+
.installed.cfg
|
|
51
|
+
*.egg
|
|
52
|
+
MANIFEST
|
|
53
|
+
*.manifest
|
|
54
|
+
*.spec
|
|
55
|
+
pip-log.txt
|
|
56
|
+
pip-delete-this-directory.txt
|
|
57
|
+
htmlcov/
|
|
58
|
+
.tox/
|
|
59
|
+
.nox/
|
|
60
|
+
.coverage
|
|
61
|
+
.coverage.*
|
|
62
|
+
.cache
|
|
63
|
+
nosetests.xml
|
|
64
|
+
coverage.xml
|
|
65
|
+
*.cover
|
|
66
|
+
*.py,cover
|
|
67
|
+
.hypothesis/
|
|
68
|
+
.pytest_cache/
|
|
69
|
+
cover/
|
|
70
|
+
*.mo
|
|
71
|
+
*.pot
|
|
72
|
+
*.log
|
|
73
|
+
local_settings.py
|
|
74
|
+
db.sqlite3
|
|
75
|
+
db.sqlite3-journal
|
|
76
|
+
instance/
|
|
77
|
+
.webassets-cache
|
|
78
|
+
.scrapy
|
|
79
|
+
docs/_build/
|
|
80
|
+
.pybuilder/
|
|
81
|
+
target/
|
|
82
|
+
.ipynb_checkpoints
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
.pdm.toml
|
|
86
|
+
__pypackages__/
|
|
87
|
+
celerybeat-schedule
|
|
88
|
+
celerybeat.pid
|
|
89
|
+
*.sage.py
|
|
90
|
+
.env
|
|
91
|
+
.venv
|
|
92
|
+
env/
|
|
93
|
+
venv/
|
|
94
|
+
ENV/
|
|
95
|
+
env.bak/
|
|
96
|
+
venv.bak/
|
|
97
|
+
.spyderproject
|
|
98
|
+
.spyproject
|
|
99
|
+
.ropeproject
|
|
100
|
+
/site
|
|
101
|
+
.mypy_cache/
|
|
102
|
+
.dmypy.json
|
|
103
|
+
dmypy.json
|
|
104
|
+
.pyre/
|
|
105
|
+
.pytype/
|
|
106
|
+
cython_debug/
|
|
107
|
+
.idea
|
|
108
|
+
.idea
|
|
109
|
+
alembic
|
|
110
|
+
*.db
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# To learn more about how to use Nix to configure your environment
|
|
2
|
+
# see: https://developers.google.com/idx/guides/customize-idx-env
|
|
3
|
+
{ pkgs, ... }: {
|
|
4
|
+
# Which nixpkgs channel to use.
|
|
5
|
+
channel = "stable-23.11"; # or "unstable"
|
|
6
|
+
|
|
7
|
+
# Use https://search.nixos.org/packages to find packages
|
|
8
|
+
packages = [
|
|
9
|
+
pkgs.python3
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
# Sets environment variables in the workspace
|
|
13
|
+
env = {};
|
|
14
|
+
idx = {
|
|
15
|
+
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
|
|
16
|
+
extensions = [
|
|
17
|
+
"ms-python.python"
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
# Workspace lifecycle hooks
|
|
21
|
+
workspace = {
|
|
22
|
+
# Runs when a workspace is first created
|
|
23
|
+
onCreate = {
|
|
24
|
+
create-venv = ''
|
|
25
|
+
python -m venv .venv
|
|
26
|
+
source .venv/bin/activate
|
|
27
|
+
pip install -e .[test,docs]
|
|
28
|
+
'';
|
|
29
|
+
};
|
|
30
|
+
# Runs when the workspace is (re)started
|
|
31
|
+
onStart = {
|
|
32
|
+
#activate-venv = ''
|
|
33
|
+
# echo "source .venv/bin/activate" >> ~/.bashrc
|
|
34
|
+
#'';
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}
|
lightapi-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 iklobato
|
|
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.
|
lightapi-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lightapi
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A lightweight framework for building API endpoints using Python's native libraries.
|
|
5
|
+
Project-URL: Repository, https://github.com/henriqueblobato/LightApi
|
|
6
|
+
Project-URL: Issues, https://github.com/henriqueblobato/LightApi/issues
|
|
7
|
+
Project-URL: Homepage, https://github.com/henriqueblobato/LightApi
|
|
8
|
+
Author-email: iklobato <iklobato1@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,endpoint,framework,lightweight,rest,restful
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
20
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
|
+
Requires-Python: >=3.8.1
|
|
23
|
+
Requires-Dist: aiohttp<4.0.0,>=3.9.5
|
|
24
|
+
Requires-Dist: pyjwt<3.0.0,>=2.8.0
|
|
25
|
+
Requires-Dist: redis<6.0.0,>=5.0.0
|
|
26
|
+
Requires-Dist: sqlalchemy<3.0.0,>=2.0.30
|
|
27
|
+
Requires-Dist: starlette<1.0.0,>=0.37.0
|
|
28
|
+
Requires-Dist: uvicorn<1.0.0,>=0.30.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: black<24.0.0,>=23.3.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: flake8<7.0.0,>=6.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: isort<6.0.0,>=5.12.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: mypy<2.0.0,>=1.3.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest<8.0.0,>=7.3.1; extra == 'dev'
|
|
35
|
+
Provides-Extra: docs
|
|
36
|
+
Requires-Dist: mkdocs-awesome-pages-plugin; extra == 'docs'
|
|
37
|
+
Requires-Dist: mkdocs-git-authors-plugin; extra == 'docs'
|
|
38
|
+
Requires-Dist: mkdocs-git-committers-plugin-2; extra == 'docs'
|
|
39
|
+
Requires-Dist: mkdocs-git-revision-date-localized-plugin; extra == 'docs'
|
|
40
|
+
Requires-Dist: mkdocs-glightbox; extra == 'docs'
|
|
41
|
+
Requires-Dist: mkdocs-material; extra == 'docs'
|
|
42
|
+
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
43
|
+
Provides-Extra: test
|
|
44
|
+
Requires-Dist: httpx<1.0.0,>=0.27.0; extra == 'test'
|
|
45
|
+
Requires-Dist: pyjwt<3.0.0,>=2.8.0; extra == 'test'
|
|
46
|
+
Requires-Dist: pytest<8.0.0,>=7.3.1; extra == 'test'
|
|
47
|
+
Requires-Dist: redis<6.0.0,>=5.0.0; extra == 'test'
|
|
48
|
+
Requires-Dist: starlette<1.0.0,>=0.37.0; extra == 'test'
|
|
49
|
+
Requires-Dist: uvicorn<1.0.0,>=0.30.0; extra == 'test'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# LightAPI
|
|
53
|
+
|
|
54
|
+
[](https://badge.fury.io/py/lightapi)
|
|
55
|
+
[](https://www.python.org/downloads/)
|
|
56
|
+
[](https://opensource.org/licenses/MIT)
|
|
57
|
+
|
|
58
|
+
A lightweight, fast, and easy-to-use web API framework for Python with automatic REST endpoint generation, built-in authentication, caching, and more.
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- 🚀 **Zero-boilerplate REST APIs** - Automatically generate CRUD operations from SQLAlchemy models
|
|
63
|
+
- 🔐 **Built-in Authentication** - JWT authentication with automatic CORS handling
|
|
64
|
+
- ⚡ **High Performance** - Built on Starlette for async support and speed
|
|
65
|
+
- 💾 **Smart Caching** - Redis-based caching with automatic invalidation
|
|
66
|
+
- 📊 **Request Validation** - Automatic request validation and error handling
|
|
67
|
+
- 🔍 **Advanced Filtering** - Query filtering, pagination, and sorting out of the box
|
|
68
|
+
- 📖 **Auto Documentation** - Automatic OpenAPI/Swagger documentation generation
|
|
69
|
+
- 🔧 **Flexible Middleware** - Easy middleware system for custom logic
|
|
70
|
+
- 🗄️ **Database Integration** - Seamless SQLAlchemy integration with automatic table creation
|
|
71
|
+
- ⚙️ **Environment Configuration** - Easy configuration management
|
|
72
|
+
|
|
73
|
+
## Quick Start
|
|
74
|
+
|
|
75
|
+
### Installation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install lightapi
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Basic Usage
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from lightapi import LightApi
|
|
85
|
+
from lightapi.database import Base
|
|
86
|
+
from sqlalchemy import Column, Integer, String
|
|
87
|
+
|
|
88
|
+
# Define your model
|
|
89
|
+
class User(Base):
|
|
90
|
+
__tablename__ = "users"
|
|
91
|
+
|
|
92
|
+
id = Column(Integer, primary_key=True)
|
|
93
|
+
name = Column(String(50))
|
|
94
|
+
email = Column(String(100))
|
|
95
|
+
|
|
96
|
+
# Create API instance
|
|
97
|
+
app = LightApi()
|
|
98
|
+
|
|
99
|
+
# Register your model - automatically creates CRUD endpoints
|
|
100
|
+
app.register(User)
|
|
101
|
+
|
|
102
|
+
# Run the server
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
app.run()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That's it! You now have a fully functional REST API with:
|
|
108
|
+
- `GET /users` - List all users with filtering and pagination
|
|
109
|
+
- `GET /users/{id}` - Get user by ID
|
|
110
|
+
- `POST /users` - Create new user
|
|
111
|
+
- `PUT /users/{id}` - Update user
|
|
112
|
+
- `DELETE /users/{id}` - Delete user
|
|
113
|
+
- `OPTIONS /users` - CORS preflight support
|
|
114
|
+
|
|
115
|
+
## Documentation
|
|
116
|
+
|
|
117
|
+
Visit our comprehensive documentation at: https://iklobato.github.io/lightapi/
|
|
118
|
+
|
|
119
|
+
- [Getting Started Guide](https://iklobato.github.io/lightapi/getting-started/installation/)
|
|
120
|
+
- [API Reference](https://iklobato.github.io/lightapi/api-reference/core/)
|
|
121
|
+
- [Examples](https://iklobato.github.io/lightapi/examples/basic-rest/)
|
|
122
|
+
|
|
123
|
+
## Advanced Features
|
|
124
|
+
|
|
125
|
+
### Authentication
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from lightapi.auth import JWTAuthentication
|
|
129
|
+
|
|
130
|
+
# Add JWT authentication
|
|
131
|
+
auth = JWTAuthentication(secret_key="your-secret-key")
|
|
132
|
+
app.add_middleware(auth)
|
|
133
|
+
|
|
134
|
+
# Protected endpoints automatically require valid JWT tokens
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Caching
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from lightapi.cache import RedisCache
|
|
141
|
+
|
|
142
|
+
# Add Redis caching
|
|
143
|
+
cache = RedisCache(host="localhost", port=6379)
|
|
144
|
+
app.register(User, cache=cache, cache_ttl=300) # 5 minutes TTL
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Validation
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from lightapi.rest import Validator
|
|
151
|
+
|
|
152
|
+
class UserValidator(Validator):
|
|
153
|
+
def validate_post(self, data):
|
|
154
|
+
if not data.get("email"):
|
|
155
|
+
raise ValueError("Email is required")
|
|
156
|
+
return data
|
|
157
|
+
|
|
158
|
+
app.register(User, validator=UserValidator())
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Middleware
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from lightapi.core import Middleware
|
|
165
|
+
|
|
166
|
+
class LoggingMiddleware(Middleware):
|
|
167
|
+
async def process(self, request, call_next):
|
|
168
|
+
print(f"Request: {request.method} {request.url}")
|
|
169
|
+
response = await call_next(request)
|
|
170
|
+
print(f"Response: {response.status_code}")
|
|
171
|
+
return response
|
|
172
|
+
|
|
173
|
+
app.add_middleware(LoggingMiddleware())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Why LightAPI?
|
|
177
|
+
|
|
178
|
+
- **Rapid Development**: Get REST APIs running in minutes, not hours
|
|
179
|
+
- **Production Ready**: Built-in security, caching, and error handling
|
|
180
|
+
- **Flexible**: Customize every aspect while keeping defaults simple
|
|
181
|
+
- **Modern**: Async support, type hints, and contemporary Python practices
|
|
182
|
+
- **Well Documented**: Comprehensive docs with real-world examples
|
|
183
|
+
|
|
184
|
+
## Examples
|
|
185
|
+
|
|
186
|
+
Check out the [examples directory](./examples/) for complete applications:
|
|
187
|
+
|
|
188
|
+
- [Basic REST API](./examples/basic_rest_api.py) - Simple CRUD operations
|
|
189
|
+
- [Authentication](./examples/auth_example.py) - JWT authentication
|
|
190
|
+
- [Caching](./examples/caching_example.py) - Redis caching implementation
|
|
191
|
+
- [Validation](./examples/validation_example.py) - Request validation
|
|
192
|
+
- [Middleware](./examples/middleware_example.py) - Custom middleware
|
|
193
|
+
- [Filtering & Pagination](./examples/filtering_pagination_example.py) - Advanced queries
|
|
194
|
+
|
|
195
|
+
## Contributing
|
|
196
|
+
|
|
197
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
**LightAPI** - *Making web APIs light and fast* ⚡
|
|
206
|
+
|
|
207
|
+
<!-- Testing development pipeline -->
|