py-turbo-api 1.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.
Files changed (43) hide show
  1. py_turbo_api-1.0.1/LICENSE +149 -0
  2. py_turbo_api-1.0.1/NOTICE +4 -0
  3. py_turbo_api-1.0.1/PKG-INFO +99 -0
  4. py_turbo_api-1.0.1/README.md +67 -0
  5. py_turbo_api-1.0.1/py_turbo_api.egg-info/PKG-INFO +99 -0
  6. py_turbo_api-1.0.1/py_turbo_api.egg-info/SOURCES.txt +41 -0
  7. py_turbo_api-1.0.1/py_turbo_api.egg-info/dependency_links.txt +1 -0
  8. py_turbo_api-1.0.1/py_turbo_api.egg-info/requires.txt +10 -0
  9. py_turbo_api-1.0.1/py_turbo_api.egg-info/top_level.txt +1 -0
  10. py_turbo_api-1.0.1/pyproject.toml +48 -0
  11. py_turbo_api-1.0.1/setup.cfg +4 -0
  12. py_turbo_api-1.0.1/tests/test_app_release.py +133 -0
  13. py_turbo_api-1.0.1/tests/test_body_parsing_breadth.py +190 -0
  14. py_turbo_api-1.0.1/tests/test_fuzz_hardening.py +85 -0
  15. py_turbo_api-1.0.1/tests/test_middleware_ecosystem.py +406 -0
  16. py_turbo_api-1.0.1/tests/test_models.py +130 -0
  17. py_turbo_api-1.0.1/tests/test_observability.py +168 -0
  18. py_turbo_api-1.0.1/tests/test_openapi_depth.py +117 -0
  19. py_turbo_api-1.0.1/tests/test_params_and_serialization.py +187 -0
  20. py_turbo_api-1.0.1/tests/test_response_depth_and_ops.py +196 -0
  21. py_turbo_api-1.0.1/tests/test_router.py +8 -0
  22. py_turbo_api-1.0.1/tests/test_router_surface.py +169 -0
  23. py_turbo_api-1.0.1/tests/test_runtime_parity.py +209 -0
  24. py_turbo_api-1.0.1/tests/test_security.py +234 -0
  25. py_turbo_api-1.0.1/tests/test_soak_runtime.py +38 -0
  26. py_turbo_api-1.0.1/tests/test_sync_execution.py +72 -0
  27. py_turbo_api-1.0.1/tests/test_testing_dx.py +61 -0
  28. py_turbo_api-1.0.1/tests/test_ws_and_openapi_maturity.py +204 -0
  29. py_turbo_api-1.0.1/turbo/__init__.py +53 -0
  30. py_turbo_api-1.0.1/turbo/app.py +837 -0
  31. py_turbo_api-1.0.1/turbo/config.py +85 -0
  32. py_turbo_api-1.0.1/turbo/deps.py +330 -0
  33. py_turbo_api-1.0.1/turbo/errors.py +6 -0
  34. py_turbo_api-1.0.1/turbo/middleware.py +690 -0
  35. py_turbo_api-1.0.1/turbo/models.py +652 -0
  36. py_turbo_api-1.0.1/turbo/observability.py +534 -0
  37. py_turbo_api-1.0.1/turbo/openapi.py +388 -0
  38. py_turbo_api-1.0.1/turbo/request.py +730 -0
  39. py_turbo_api-1.0.1/turbo/response.py +463 -0
  40. py_turbo_api-1.0.1/turbo/routing.py +118 -0
  41. py_turbo_api-1.0.1/turbo/security.py +434 -0
  42. py_turbo_api-1.0.1/turbo/testing.py +180 -0
  43. py_turbo_api-1.0.1/turbo/utils.py +25 -0
@@ -0,0 +1,149 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+ "License" shall mean the terms and conditions for use, reproduction,
9
+ and distribution as defined by Sections 1 through 9 of this document.
10
+ "Licensor" shall mean the copyright owner or entity authorized by
11
+ the copyright owner that is granting the License.
12
+ "Legal Entity" shall mean the union of the acting entity and all
13
+ other entities that control, are controlled by, or are under common
14
+ control with that entity. For the purposes of this definition,
15
+ "control" means (i) the power, direct or indirect, to cause the
16
+ direction or management of such entity, whether by contract or
17
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
18
+ outstanding shares, or (iii) beneficial ownership of such entity.
19
+ "You" (or "Your") shall mean an individual or Legal Entity
20
+ exercising permissions granted by this License.
21
+ "Source" form shall mean the preferred form for making modifications,
22
+ including but not limited to software source code, documentation
23
+ source, and configuration files.
24
+ "Object" form shall mean any form resulting from mechanical
25
+ transformation or translation of a Source form, including but not
26
+ limited to compiled object code, generated documentation,
27
+ and conversions to other media types.
28
+ "Work" shall mean the work of authorship, whether in Source or
29
+ Object form, made available under the License, as indicated by a
30
+ copyright notice that is included in or attached to the work
31
+ (an example is provided in the Appendix below).
32
+ "Derivative Works" shall mean any work, whether in Source or Object
33
+ form, that is based on (or derived from) the Work and for which the
34
+ editorial revisions, annotations, elaborations, or other modifications
35
+ represent, as a whole, an original work of authorship. For the purposes
36
+ of this License, Derivative Works shall not include works that remain
37
+ separable from, or merely link (or bind by name) to the interfaces of,
38
+ the Work and Derivative Works thereof.
39
+ "Contribution" shall mean any work of authorship, including
40
+ the original version of the Work and any modifications or additions
41
+ to that Work or Derivative Works thereof, that is intentionally
42
+ submitted to Licensor for inclusion in the Work by the copyright owner
43
+ or by an individual or Legal Entity authorized to submit on behalf of
44
+ the copyright owner. For the purposes of this definition, "submitted"
45
+ means any form of electronic, verbal, or written communication sent
46
+ to the Licensor or its representatives, including but not limited to
47
+ communication on electronic mailing lists, source code control systems,
48
+ and issue tracking systems that are managed by, or on behalf of, the
49
+ Licensor for the purpose of discussing and improving the Work, but
50
+ excluding communication that is conspicuously marked or otherwise
51
+ designated in writing by the copyright owner as "Not a Contribution."
52
+ "Contributor" shall mean Licensor and any individual or Legal Entity
53
+ on behalf of whom a Contribution has been received by Licensor and
54
+ subsequently incorporated within the Work.
55
+
56
+ 2. Grant of Copyright License. Subject to the terms and conditions of
57
+ this License, each Contributor hereby grants to You a perpetual,
58
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
59
+ copyright license to reproduce, prepare Derivative Works of,
60
+ publicly display, publicly perform, sublicense, and distribute the
61
+ Work and such Derivative Works in Source or Object form.
62
+
63
+ 3. Grant of Patent License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ (except as stated in this section) patent license to make, have made,
67
+ use, offer to sell, sell, import, and otherwise transfer the Work,
68
+ where such license applies only to those patent claims licensable
69
+ by such Contributor that are necessarily infringed by their
70
+ Contribution(s) alone or by combination of their Contribution(s)
71
+ with the Work to which such Contribution(s) was submitted. If You
72
+ institute patent litigation against any entity (including a
73
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
74
+ or a Contribution incorporated within the Work constitutes direct
75
+ or contributory patent infringement, then any patent licenses
76
+ granted to You under this License for that Work shall terminate
77
+ as of the date such litigation is filed.
78
+
79
+ 4. Redistribution. You may reproduce and distribute copies of the
80
+ Work or Derivative Works thereof in any medium, with or without
81
+ modifications, and in Source or Object form, provided that You
82
+ meet the following conditions:
83
+ (a) You must give any other recipients of the Work or
84
+ Derivative Works a copy of this License; and
85
+ (b) You must cause any modified files to carry prominent notices
86
+ stating that You changed the files; and
87
+ (c) You must retain, in the Source form of any Derivative Works
88
+ that You distribute, all copyright, patent, trademark, and
89
+ attribution notices from the Source form of the Work,
90
+ excluding those notices that do not pertain to any part of
91
+ the Derivative Works; and
92
+ (d) If the Work includes a "NOTICE" text file as part of its
93
+ distribution, then any Derivative Works that You distribute must
94
+ include a readable copy of the attribution notices contained
95
+ within such NOTICE file, excluding those notices that do not
96
+ pertain to any part of the Derivative Works, in at least one
97
+ of the following places: within a NOTICE text file distributed
98
+ as part of the Derivative Works; within the Source form or
99
+ documentation, if provided along with the Derivative Works; or,
100
+ within a display generated by the Derivative Works, if and
101
+ wherever such third-party notices normally appear. The contents
102
+ of the NOTICE file are for informational purposes only and
103
+ do not modify the License.
104
+
105
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
106
+ any Contribution intentionally submitted for inclusion in the Work
107
+ by You to the Licensor shall be under the terms and conditions of
108
+ this License, without any additional terms or conditions.
109
+
110
+ 6. Trademarks. This License does not grant permission to use the trade
111
+ names, trademarks, service marks, or product names of the Licensor,
112
+ except as required for reasonable and customary use in describing the
113
+ origin of the Work and reproducing the content of the NOTICE file.
114
+
115
+ 7. Disclaimer of Warranty. Unless required by applicable law or
116
+ agreed to in writing, Licensor provides the Work (and each
117
+ Contributor provides its Contributions) on an "AS IS" BASIS,
118
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
119
+ implied, including, without limitation, any warranties or conditions
120
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
121
+ PARTICULAR PURPOSE.
122
+
123
+ 8. Limitation of Liability. In no event and under no legal theory,
124
+ whether in tort (including negligence), contract, or otherwise,
125
+ unless required by applicable law, shall any Contributor be
126
+ liable to You for damages.
127
+
128
+ 9. Accepting Warranty or Additional Liability. While redistributing
129
+ the Work or Derivative Works thereof, You may choose to offer,
130
+ and charge a fee for, acceptance of support, warranty, indemnity,
131
+ or other liability obligations, but only on Your own behalf.
132
+
133
+ END OF TERMS AND CONDITIONS
134
+
135
+ APPENDIX: How to apply the Apache License to your work.
136
+
137
+ Copyright 2026 Paresh Panat
138
+
139
+ Licensed under the Apache License, Version 2.0 (the "License");
140
+ you may not use this file except in compliance with the License.
141
+ You may obtain a copy of the License at
142
+
143
+ http://www.apache.org/licenses/LICENSE-2.0
144
+
145
+ Unless required by applicable law or agreed to in writing, software
146
+ distributed under the License is distributed on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148
+ See the License for the specific language governing permissions and
149
+ limitations under the License.
@@ -0,0 +1,4 @@
1
+ TurboAPI
2
+ Copyright (c) 2026 Paresh Panat
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-turbo-api
3
+ Version: 1.0.1
4
+ Summary: TurboAPI - a high-performance ASGI framework with compiled routing, DI, validation, and OpenAPI.
5
+ Author: Paresh Panat
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/pareshpanat/turboapi
8
+ Project-URL: Repository, https://github.com/pareshpanat/turboapi
9
+ Project-URL: Issues, https://github.com/pareshpanat/turboapi/issues
10
+ Keywords: asgi,web,framework,api,openapi,performance
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Provides-Extra: dev
24
+ Requires-Dist: uvicorn>=0.23; extra == "dev"
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Requires-Dist: pytest-cov>=5; extra == "dev"
27
+ Requires-Dist: ruff>=0.6; extra == "dev"
28
+ Requires-Dist: mypy>=1.10; extra == "dev"
29
+ Provides-Extra: security
30
+ Requires-Dist: PyJWT[crypto]>=2.8; extra == "security"
31
+ Dynamic: license-file
32
+
33
+ # py-turbo-api
34
+
35
+ TurboAPI is a small, fast ASGI web framework built from scratch (stdlib-only) with a focus on predictable performance.
36
+
37
+ ## Features
38
+ - Trie router with `{param}` path params
39
+ - `APIRouter` composition with prefixes/tags via `include_router()`
40
+ - Compiled route plans (signature inspection happens at route registration, not per request)
41
+ - Dependency injection with `Depends()` including nested and yield-based dependencies
42
+ - Parameter source markers: `Query`, `Header`, `Cookie`, `Form`, `File`
43
+ - Built-in validation with `Model` + `field()` (supports `Annotated`, `Literal`, `Enum`, `datetime`, `UUID`, `Decimal`)
44
+ - Multipart/form-data parsing with `UploadFile`
45
+ - Multipart hardening: per-file/part/field limits + upload spooling to disk
46
+ - `StreamingResponse`, `FileResponse`, `BackgroundTask`, and static file mounting
47
+ - Response primitives: `RedirectResponse`, `NegotiatedResponse`, cache header helpers, and `EventSourceResponse` for SSE
48
+ - File hardening: `ETag`/`If-None-Match` + byte range (`206`/`416`) support
49
+ - WebSocket route support via `@app.websocket(...)`
50
+ - Sub-app mounting via `app.mount("/prefix", sub_app)` and host routing via `app.mount_host("*.example.com", app)`
51
+ - WebSocket auth helpers (`websocket_token_auth`, `websocket_jwt_auth`) and OpenAPI WS extension docs (`x-turbo-websockets`)
52
+ - Security primitives: `api_key_auth()`, `bearer_auth()`, `jwt_auth()`, OAuth2 password/auth-code/client-credentials helpers with OpenAPI security schemas
53
+ - Session + CSRF protection primitives (`SessionMiddleware`, `CSRFMiddleware`, CSRF helpers)
54
+ - OpenAPI at `/openapi.json`
55
+ - Swagger UI at `/docs` and ReDoc at `/redoc`
56
+ - Lifespan startup/shutdown handlers
57
+ - Custom exception handlers with `@app.exception_handler(...)`
58
+ - Reliability defaults: request timeout, max body size, max concurrency
59
+ - Runtime settings model (`TurboSettings`) + `Turbo.from_env()` for env-driven deploy config
60
+ - Graceful shutdown request draining (`shutdown_drain_timeout`)
61
+ - CI release gates: Python matrix tests/lint + package build and `twine check`, with trusted publishing workflow
62
+ - Benchmark suite + perf regression gates in CI (`benchmarks/bench_runtime.py`)
63
+
64
+ ## Stability
65
+ - Compatibility policy: `API_COMPATIBILITY.md`
66
+ - Current status: pre-1.0 (public API is stabilizing toward `v1.0.0`)
67
+
68
+ ## Install
69
+
70
+ ### From PyPI
71
+ ```bash
72
+ pip install py-turbo-api
73
+ ```
74
+
75
+ PyPI: https://pypi.org/project/py-turbo-api/
76
+
77
+ ## Run example
78
+ ```bash
79
+ uvicorn app:app --reload
80
+ ```
81
+
82
+ Open:
83
+ - http://127.0.0.1:8000/docs
84
+ - http://127.0.0.1:8000/openapi.json
85
+
86
+ ## Documentation Tracks
87
+ - Tutorial: `docs/tutorial.md`
88
+ - Advanced: `docs/advanced.md`
89
+ - Deployment: `docs/deployment.md`
90
+ - Security recipes: `docs/security-recipes.md`
91
+ - Why TurboAPI + benchmark method: `docs/why-turboapi.md`
92
+
93
+ ## Benchmarks
94
+ ```bash
95
+ python benchmarks/bench_runtime.py --baseline benchmarks/baseline.json --tolerance 1.20 --gate
96
+ ```
97
+
98
+ ## License
99
+ Apache-2.0 (see LICENSE).
@@ -0,0 +1,67 @@
1
+ # py-turbo-api
2
+
3
+ TurboAPI is a small, fast ASGI web framework built from scratch (stdlib-only) with a focus on predictable performance.
4
+
5
+ ## Features
6
+ - Trie router with `{param}` path params
7
+ - `APIRouter` composition with prefixes/tags via `include_router()`
8
+ - Compiled route plans (signature inspection happens at route registration, not per request)
9
+ - Dependency injection with `Depends()` including nested and yield-based dependencies
10
+ - Parameter source markers: `Query`, `Header`, `Cookie`, `Form`, `File`
11
+ - Built-in validation with `Model` + `field()` (supports `Annotated`, `Literal`, `Enum`, `datetime`, `UUID`, `Decimal`)
12
+ - Multipart/form-data parsing with `UploadFile`
13
+ - Multipart hardening: per-file/part/field limits + upload spooling to disk
14
+ - `StreamingResponse`, `FileResponse`, `BackgroundTask`, and static file mounting
15
+ - Response primitives: `RedirectResponse`, `NegotiatedResponse`, cache header helpers, and `EventSourceResponse` for SSE
16
+ - File hardening: `ETag`/`If-None-Match` + byte range (`206`/`416`) support
17
+ - WebSocket route support via `@app.websocket(...)`
18
+ - Sub-app mounting via `app.mount("/prefix", sub_app)` and host routing via `app.mount_host("*.example.com", app)`
19
+ - WebSocket auth helpers (`websocket_token_auth`, `websocket_jwt_auth`) and OpenAPI WS extension docs (`x-turbo-websockets`)
20
+ - Security primitives: `api_key_auth()`, `bearer_auth()`, `jwt_auth()`, OAuth2 password/auth-code/client-credentials helpers with OpenAPI security schemas
21
+ - Session + CSRF protection primitives (`SessionMiddleware`, `CSRFMiddleware`, CSRF helpers)
22
+ - OpenAPI at `/openapi.json`
23
+ - Swagger UI at `/docs` and ReDoc at `/redoc`
24
+ - Lifespan startup/shutdown handlers
25
+ - Custom exception handlers with `@app.exception_handler(...)`
26
+ - Reliability defaults: request timeout, max body size, max concurrency
27
+ - Runtime settings model (`TurboSettings`) + `Turbo.from_env()` for env-driven deploy config
28
+ - Graceful shutdown request draining (`shutdown_drain_timeout`)
29
+ - CI release gates: Python matrix tests/lint + package build and `twine check`, with trusted publishing workflow
30
+ - Benchmark suite + perf regression gates in CI (`benchmarks/bench_runtime.py`)
31
+
32
+ ## Stability
33
+ - Compatibility policy: `API_COMPATIBILITY.md`
34
+ - Current status: pre-1.0 (public API is stabilizing toward `v1.0.0`)
35
+
36
+ ## Install
37
+
38
+ ### From PyPI
39
+ ```bash
40
+ pip install py-turbo-api
41
+ ```
42
+
43
+ PyPI: https://pypi.org/project/py-turbo-api/
44
+
45
+ ## Run example
46
+ ```bash
47
+ uvicorn app:app --reload
48
+ ```
49
+
50
+ Open:
51
+ - http://127.0.0.1:8000/docs
52
+ - http://127.0.0.1:8000/openapi.json
53
+
54
+ ## Documentation Tracks
55
+ - Tutorial: `docs/tutorial.md`
56
+ - Advanced: `docs/advanced.md`
57
+ - Deployment: `docs/deployment.md`
58
+ - Security recipes: `docs/security-recipes.md`
59
+ - Why TurboAPI + benchmark method: `docs/why-turboapi.md`
60
+
61
+ ## Benchmarks
62
+ ```bash
63
+ python benchmarks/bench_runtime.py --baseline benchmarks/baseline.json --tolerance 1.20 --gate
64
+ ```
65
+
66
+ ## License
67
+ Apache-2.0 (see LICENSE).
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-turbo-api
3
+ Version: 1.0.1
4
+ Summary: TurboAPI - a high-performance ASGI framework with compiled routing, DI, validation, and OpenAPI.
5
+ Author: Paresh Panat
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/pareshpanat/turboapi
8
+ Project-URL: Repository, https://github.com/pareshpanat/turboapi
9
+ Project-URL: Issues, https://github.com/pareshpanat/turboapi/issues
10
+ Keywords: asgi,web,framework,api,openapi,performance
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Provides-Extra: dev
24
+ Requires-Dist: uvicorn>=0.23; extra == "dev"
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Requires-Dist: pytest-cov>=5; extra == "dev"
27
+ Requires-Dist: ruff>=0.6; extra == "dev"
28
+ Requires-Dist: mypy>=1.10; extra == "dev"
29
+ Provides-Extra: security
30
+ Requires-Dist: PyJWT[crypto]>=2.8; extra == "security"
31
+ Dynamic: license-file
32
+
33
+ # py-turbo-api
34
+
35
+ TurboAPI is a small, fast ASGI web framework built from scratch (stdlib-only) with a focus on predictable performance.
36
+
37
+ ## Features
38
+ - Trie router with `{param}` path params
39
+ - `APIRouter` composition with prefixes/tags via `include_router()`
40
+ - Compiled route plans (signature inspection happens at route registration, not per request)
41
+ - Dependency injection with `Depends()` including nested and yield-based dependencies
42
+ - Parameter source markers: `Query`, `Header`, `Cookie`, `Form`, `File`
43
+ - Built-in validation with `Model` + `field()` (supports `Annotated`, `Literal`, `Enum`, `datetime`, `UUID`, `Decimal`)
44
+ - Multipart/form-data parsing with `UploadFile`
45
+ - Multipart hardening: per-file/part/field limits + upload spooling to disk
46
+ - `StreamingResponse`, `FileResponse`, `BackgroundTask`, and static file mounting
47
+ - Response primitives: `RedirectResponse`, `NegotiatedResponse`, cache header helpers, and `EventSourceResponse` for SSE
48
+ - File hardening: `ETag`/`If-None-Match` + byte range (`206`/`416`) support
49
+ - WebSocket route support via `@app.websocket(...)`
50
+ - Sub-app mounting via `app.mount("/prefix", sub_app)` and host routing via `app.mount_host("*.example.com", app)`
51
+ - WebSocket auth helpers (`websocket_token_auth`, `websocket_jwt_auth`) and OpenAPI WS extension docs (`x-turbo-websockets`)
52
+ - Security primitives: `api_key_auth()`, `bearer_auth()`, `jwt_auth()`, OAuth2 password/auth-code/client-credentials helpers with OpenAPI security schemas
53
+ - Session + CSRF protection primitives (`SessionMiddleware`, `CSRFMiddleware`, CSRF helpers)
54
+ - OpenAPI at `/openapi.json`
55
+ - Swagger UI at `/docs` and ReDoc at `/redoc`
56
+ - Lifespan startup/shutdown handlers
57
+ - Custom exception handlers with `@app.exception_handler(...)`
58
+ - Reliability defaults: request timeout, max body size, max concurrency
59
+ - Runtime settings model (`TurboSettings`) + `Turbo.from_env()` for env-driven deploy config
60
+ - Graceful shutdown request draining (`shutdown_drain_timeout`)
61
+ - CI release gates: Python matrix tests/lint + package build and `twine check`, with trusted publishing workflow
62
+ - Benchmark suite + perf regression gates in CI (`benchmarks/bench_runtime.py`)
63
+
64
+ ## Stability
65
+ - Compatibility policy: `API_COMPATIBILITY.md`
66
+ - Current status: pre-1.0 (public API is stabilizing toward `v1.0.0`)
67
+
68
+ ## Install
69
+
70
+ ### From PyPI
71
+ ```bash
72
+ pip install py-turbo-api
73
+ ```
74
+
75
+ PyPI: https://pypi.org/project/py-turbo-api/
76
+
77
+ ## Run example
78
+ ```bash
79
+ uvicorn app:app --reload
80
+ ```
81
+
82
+ Open:
83
+ - http://127.0.0.1:8000/docs
84
+ - http://127.0.0.1:8000/openapi.json
85
+
86
+ ## Documentation Tracks
87
+ - Tutorial: `docs/tutorial.md`
88
+ - Advanced: `docs/advanced.md`
89
+ - Deployment: `docs/deployment.md`
90
+ - Security recipes: `docs/security-recipes.md`
91
+ - Why TurboAPI + benchmark method: `docs/why-turboapi.md`
92
+
93
+ ## Benchmarks
94
+ ```bash
95
+ python benchmarks/bench_runtime.py --baseline benchmarks/baseline.json --tolerance 1.20 --gate
96
+ ```
97
+
98
+ ## License
99
+ Apache-2.0 (see LICENSE).
@@ -0,0 +1,41 @@
1
+ LICENSE
2
+ NOTICE
3
+ README.md
4
+ pyproject.toml
5
+ py_turbo_api.egg-info/PKG-INFO
6
+ py_turbo_api.egg-info/SOURCES.txt
7
+ py_turbo_api.egg-info/dependency_links.txt
8
+ py_turbo_api.egg-info/requires.txt
9
+ py_turbo_api.egg-info/top_level.txt
10
+ tests/test_app_release.py
11
+ tests/test_body_parsing_breadth.py
12
+ tests/test_fuzz_hardening.py
13
+ tests/test_middleware_ecosystem.py
14
+ tests/test_models.py
15
+ tests/test_observability.py
16
+ tests/test_openapi_depth.py
17
+ tests/test_params_and_serialization.py
18
+ tests/test_response_depth_and_ops.py
19
+ tests/test_router.py
20
+ tests/test_router_surface.py
21
+ tests/test_runtime_parity.py
22
+ tests/test_security.py
23
+ tests/test_soak_runtime.py
24
+ tests/test_sync_execution.py
25
+ tests/test_testing_dx.py
26
+ tests/test_ws_and_openapi_maturity.py
27
+ turbo/__init__.py
28
+ turbo/app.py
29
+ turbo/config.py
30
+ turbo/deps.py
31
+ turbo/errors.py
32
+ turbo/middleware.py
33
+ turbo/models.py
34
+ turbo/observability.py
35
+ turbo/openapi.py
36
+ turbo/request.py
37
+ turbo/response.py
38
+ turbo/routing.py
39
+ turbo/security.py
40
+ turbo/testing.py
41
+ turbo/utils.py
@@ -0,0 +1,10 @@
1
+
2
+ [dev]
3
+ uvicorn>=0.23
4
+ pytest>=8
5
+ pytest-cov>=5
6
+ ruff>=0.6
7
+ mypy>=1.10
8
+
9
+ [security]
10
+ PyJWT[crypto]>=2.8
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "py-turbo-api"
7
+ version = "1.0.1"
8
+ description = "TurboAPI - a high-performance ASGI framework with compiled routing, DI, validation, and OpenAPI."
9
+ readme = "README.md"
10
+ requires-python = ">3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ authors = [{ name = "Paresh Panat" }]
14
+ keywords = ["asgi", "web", "framework", "api", "openapi", "performance"]
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Internet :: WWW/HTTP",
23
+ "Topic :: Software Development :: Libraries",
24
+ ]
25
+ dependencies = []
26
+
27
+ [project.optional-dependencies]
28
+ dev = ["uvicorn>=0.23", "pytest>=8", "pytest-cov>=5", "ruff>=0.6", "mypy>=1.10"]
29
+ security = ["PyJWT[crypto]>=2.8"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/pareshpanat/turboapi"
33
+ Repository = "https://github.com/pareshpanat/turboapi"
34
+ Issues = "https://github.com/pareshpanat/turboapi/issues"
35
+
36
+ [tool.setuptools]
37
+ packages = ["turbo"]
38
+
39
+ [tool.pytest.ini_options]
40
+ pythonpath = ["."]
41
+
42
+ [tool.mypy]
43
+ python_version = "3.12"
44
+ warn_unused_ignores = true
45
+ ignore_missing_imports = true
46
+ check_untyped_defs = true
47
+ disallow_untyped_defs = false
48
+ warn_return_any = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,133 @@
1
+ import asyncio
2
+ import json
3
+ from turbo import Turbo, APIRouter, Depends, HTTPError, Request, Model
4
+
5
+ async def run_http(app, method="GET", path="/", query="", headers=None, body_chunks=None):
6
+ chunks = list(body_chunks or [b""])
7
+ sent = []
8
+ scope = {
9
+ "type": "http",
10
+ "method": method,
11
+ "path": path,
12
+ "query_string": query.encode("utf-8"),
13
+ "headers": headers or [],
14
+ }
15
+ events = []
16
+ for i, chunk in enumerate(chunks):
17
+ events.append({"type": "http.request", "body": chunk, "more_body": i < len(chunks) - 1})
18
+
19
+ async def receive():
20
+ if events:
21
+ return events.pop(0)
22
+ return {"type": "http.disconnect"}
23
+
24
+ async def send(msg):
25
+ sent.append(msg)
26
+
27
+ await app(scope, receive, send)
28
+ start = next(x for x in sent if x["type"] == "http.response.start")
29
+ body = b"".join(x.get("body", b"") for x in sent if x["type"] == "http.response.body")
30
+ return start["status"], body
31
+
32
+ def test_include_router_and_openapi_metadata():
33
+ app = Turbo()
34
+ router = APIRouter(prefix="/v1", tags=["items"])
35
+
36
+ @router.get("/items/{item_id}", summary="Get item", description="Fetches one item")
37
+ async def get_item(item_id: int):
38
+ return {"id": item_id}
39
+
40
+ app.include_router(router)
41
+ status, body = asyncio.run(run_http(app, path="/v1/items/7"))
42
+ assert status == 200
43
+ assert json.loads(body.decode("utf-8"))["id"] == 7
44
+
45
+ status, body = asyncio.run(run_http(app, path="/openapi.json"))
46
+ assert status == 200
47
+ doc = json.loads(body.decode("utf-8"))
48
+ op = doc["paths"]["/v1/items/{item_id}"]["get"]
49
+ assert op["summary"] == "Get item"
50
+ assert op["tags"] == ["items"]
51
+
52
+ def test_exception_handler_registration():
53
+ app = Turbo()
54
+
55
+ @app.exception_handler(ValueError)
56
+ async def handle_value_error(req, exc):
57
+ return {"error": str(exc), "kind": "value"}
58
+
59
+ @app.get("/boom")
60
+ async def boom():
61
+ raise ValueError("bad")
62
+
63
+ status, body = asyncio.run(run_http(app, path="/boom"))
64
+ assert status == 200
65
+ assert json.loads(body.decode("utf-8"))["kind"] == "value"
66
+
67
+ def test_dependency_nested_and_cleanup():
68
+ app = Turbo()
69
+ calls = []
70
+
71
+ async def get_token(req: Request):
72
+ return req.headers.get("x-token", "")
73
+
74
+ async def check_auth(token=Depends(get_token)):
75
+ return token == "ok"
76
+
77
+ async def resource():
78
+ calls.append("open")
79
+ try:
80
+ yield "db"
81
+ finally:
82
+ calls.append("close")
83
+
84
+ @app.get("/secure")
85
+ async def secure(allowed=Depends(check_auth), conn=Depends(resource)):
86
+ if not allowed:
87
+ raise HTTPError(401, "Unauthorized")
88
+ return {"conn": conn}
89
+
90
+ headers = [(b"x-token", b"ok")]
91
+ status, body = asyncio.run(run_http(app, path="/secure", headers=headers))
92
+ assert status == 200
93
+ assert json.loads(body.decode("utf-8"))["conn"] == "db"
94
+ assert calls == ["open", "close"]
95
+
96
+ def test_max_body_bytes_across_multiple_chunks():
97
+ app = Turbo(max_body_bytes=5)
98
+
99
+ class Payload(Model):
100
+ v: str
101
+
102
+ @app.post("/echo")
103
+ async def echo(payload: Payload):
104
+ return {"ok": True}
105
+
106
+ status, _ = asyncio.run(run_http(app, method="POST", path="/echo", body_chunks=[b'{"v":"ab', b'cdef"}']))
107
+ assert status == 413
108
+
109
+ def test_lifespan_startup_shutdown():
110
+ app = Turbo()
111
+ state = []
112
+
113
+ @app.on_event("startup")
114
+ async def on_startup():
115
+ state.append("startup")
116
+
117
+ @app.on_event("shutdown")
118
+ async def on_shutdown():
119
+ state.append("shutdown")
120
+
121
+ sent = []
122
+ receive_events = [{"type": "lifespan.startup"}, {"type": "lifespan.shutdown"}]
123
+
124
+ async def receive():
125
+ return receive_events.pop(0)
126
+
127
+ async def send(msg):
128
+ sent.append(msg)
129
+
130
+ asyncio.run(app({"type": "lifespan"}, receive, send))
131
+ assert state == ["startup", "shutdown"]
132
+ assert sent[0]["type"] == "lifespan.startup.complete"
133
+ assert sent[1]["type"] == "lifespan.shutdown.complete"