p40: add JustAPIApp title/version kwargs, CLI entrypoint, and release documentation
swadhinbiswas committed 3 months ago
42f4f11
1 parent 2aaa39e
commit 42f4f11
5 files changed
+66 -3
Showing 5 changed files+66-3
â–¼README.md
+21-0
| @@ -290,10 +290,31 @@ async def websocket_endpoint(ws): | ||
290 | 290 | await ws.send_text(f"Echo: {data}") |
291 | 291 | ``` |
292 | 292 | |
293 | +## Project Scaffolding CLI | |
294 | + | |
295 | +JustAPI includes an interactive project generator to create production-ready applications with zero boilerplate: | |
296 | + | |
297 | +```bash | |
298 | +# Interactive project creation (prompts for DB engine and API architecture): | |
299 | +justapi create my_app | |
300 | + | |
301 | +# Or specify flags directly: | |
302 | +justapi create analytics_app --db duckdb --api-type rest | |
303 | +justapi create graph_app --db postgres --api-type graphql | |
304 | +justapi create rpc_service --db redis --api-type grpc | |
305 | +justapi create jsonrpc_api --db sqlite --api-type jsonrpc | |
306 | +``` | |
307 | + | |
308 | +### Supported Backends & Protocols: | |
309 | +* **Databases:** Transactional SQL (`sqlite`, `postgres`, `mysql`), Analytical OLAP (`duckdb`, `clickhouse`), NoSQL (`mongodb`, `redis`). | |
310 | +* **Protocols:** REST (OpenAPI 3.1), GraphQL (GraphiQL UI), gRPC (Protobuf), JSON-RPC 2.0. | |
311 | +* **Observability:** Includes pre-built OpenTelemetry & Jaeger stack (`docker-compose.otel.yml`). | |
312 | + | |
293 | 313 | ## Features |
294 | 314 | |
295 | 315 | ### FastAPI-compatible, Rust-accelerated |
296 | 316 | |
317 | + | |
297 | 318 | JustAPI gives you the same developer experience as FastAPI, but with a Rust engine underneath. Here's what you get: |
298 | 319 | |
299 | 320 | <table> |
300 | 321 | |
â–¼crates/justapi-py/pyproject.toml
+4-0
| @@ -39,7 +39,11 @@ classifiers = [ | ||
39 | 39 | ] |
40 | 40 | dependencies = [] |
41 | 41 | |
42 | +[project.scripts] | |
43 | +justapi = "justapi.cli:main" | |
44 | + | |
42 | 45 | [project.optional-dependencies] |
46 | + | |
43 | 47 | pydantic = ["pydantic>=2.0"] |
44 | 48 | jinja = ["jinja2>=3.0"] |
45 | 49 | full = ["pydantic>=2.0", "jinja2>=3.0"] |
46 | 50 | |
â–¼crates/justapi-py/python/justapi/__main__.py
+4-0
| @@ -0,0 +1,4 @@ | ||
1 | +from justapi.cli import main | |
2 | + | |
3 | +if __name__ == "__main__": | |
4 | + main() | |
0 | 5 | |
â–¼crates/justapi-py/python/justapi/app.py
+13-3
| @@ -234,15 +234,25 @@ def adaptive_batch(max_size: int = 32, window_ms: int = 10): | ||
234 | 234 | return wrapper |
235 | 235 | |
236 | 236 | class JustAPIApp: |
237 | - def __init__(self, dependencies: typing.List[Depends] = None): | |
237 | + def __init__( | |
238 | + self, | |
239 | + title: str = "JustAPIApp", | |
240 | + version: str = "1.0.0", | |
241 | + description: str = None, | |
242 | + openapi_tags: list = None, | |
243 | + dependencies: typing.List[Depends] = None, | |
244 | + ): | |
238 | 245 | self._app = _JustAPIApp() |
246 | + self.title = title | |
247 | + self.version = version | |
248 | + self.description = description | |
249 | + self.openapi_tags = openapi_tags or [] | |
239 | 250 | self.dependencies = dependencies or [] |
240 | 251 | self.exception_handlers = {} |
241 | 252 | self.middlewares = [] |
242 | 253 | self._named_routes = {} |
243 | 254 | self.routes = [] |
244 | - self.title = "JustAPIApp" | |
245 | - self.version = "1.0.0" | |
255 | + | |
246 | 256 | |
247 | 257 | # Built-in probe/metrics endpoints for the Python app. |
248 | 258 | self.get("/health", _builtin_health, include_in_schema=False, name="builtin_health") |
249 | 259 | |
â–¼crates/justapi-py/python/justapi/cli.py
+24-0
| @@ -0,0 +1,24 @@ | ||
1 | +import sys | |
2 | +import subprocess | |
3 | +import shutil | |
4 | + | |
5 | +def main(): | |
6 | + """JustAPI CLI entrypoint for python package.""" | |
7 | + binary = shutil.which("justapi-cli") | |
8 | + if binary: | |
9 | + sys.exit(subprocess.call([binary] + sys.argv[1:])) | |
10 | + | |
11 | + if len(sys.argv) > 1 and sys.argv[1] in ("--version", "-V"): | |
12 | + print("justapi 2.0.0") | |
13 | + return | |
14 | + | |
15 | + print("🚀 JustAPI Runtime v2.0.0 (Python package)") | |
16 | + print("Commands:") | |
17 | + print(" justapi --version Display version") | |
18 | + print(" python -m app.main Run application directly") | |
19 | + print("\nFor high-performance Rust CLI features (justapi create, serve --reload, profile),") | |
20 | + print("install justapi-cli via cargo: cargo install justapi-cli") | |
21 | + | |
22 | +if __name__ == "__main__": | |
23 | + main() | |
24 | + | |
0 | 25 | |