p8a-b: add CLI Reference and Configuration Reference pages
swadhinbiswas committed 3 months ago
14cecb9
1 parent c40a33b
commit 14cecb9
2 files changed
+203 -0
Showing 2 changed files+203-0
▼docs_site/src/content/docs/reference/cli.md
+133-0
| @@ -0,0 +1,133 @@ | ||
1 | +--- | |
2 | +title: CLI Reference | |
3 | +description: Complete reference for the justapi command-line tool. | |
4 | +--- | |
5 | + | |
6 | +The `justapi` CLI provides development, scaffolding, and management commands. | |
7 | + | |
8 | +## Installation | |
9 | + | |
10 | +```bash | |
11 | +cargo install justapi-cli | |
12 | +justapi --version | |
13 | +``` | |
14 | + | |
15 | +## Commands | |
16 | + | |
17 | +### `justapi serve` | |
18 | + | |
19 | +Start the development or production server. | |
20 | + | |
21 | +```bash | |
22 | +justapi serve [OPTIONS] | |
23 | +``` | |
24 | + | |
25 | +| Flag | Default | Description | | |
26 | +|---|---|---| | |
27 | +| `--host` | `127.0.0.1` | Bind address | | |
28 | +| `--port` | `8000` | Bind port | | |
29 | +| `--workers` | CPU count | Number of worker processes | | |
30 | +| `--reload` | false | Enable hot-reload on file changes | | |
31 | +| `--timeout` | 30 | Request timeout (seconds) | | |
32 | +| `--unix` | — | Unix socket path | | |
33 | +| `--scale` | false | Enable load-based auto-scaling | | |
34 | +| `--min-workers` | 2 | Minimum workers (with --scale) | | |
35 | +| `--max-workers` | CPU count | Maximum workers (with --scale) | | |
36 | +| `--scale-low` | 100 | RPS to scale down | | |
37 | +| `--scale-high` | 1000 | RPS to scale up | | |
38 | +| `--scale-cooldown` | 30 | Seconds between scaling events | | |
39 | + | |
40 | +### `justapi create` | |
41 | + | |
42 | +Generate a new project from a template. | |
43 | + | |
44 | +```bash | |
45 | +justapi create [OPTIONS] <project_name> | |
46 | +``` | |
47 | + | |
48 | +| Flag | Default | Description | | |
49 | +|---|---|---| | |
50 | +| `--db` | (interactive) | Database engine (sqlite, postgres, mysql, duckdb, clickhouse, mongodb, redis) | | |
51 | +| `--api-type` | (interactive) | API protocol (rest, graphql, grpc, jsonrpc) | | |
52 | + | |
53 | +### `justapi db` | |
54 | + | |
55 | +Database migration commands. | |
56 | + | |
57 | +```bash | |
58 | +justapi db migrate # Apply pending migrations | |
59 | +justapi db rollback # Rollback last migration | |
60 | +justapi db list # List migration status | |
61 | +justapi db seed # Seed database with initial data | |
62 | +justapi db reset # Drop and recreate all tables | |
63 | +justapi db inspect # Inspect database schema | |
64 | +``` | |
65 | + | |
66 | +### `justapi routes` | |
67 | + | |
68 | +List all registered routes. | |
69 | + | |
70 | +```bash | |
71 | +justapi routes | |
72 | +``` | |
73 | + | |
74 | +Output: | |
75 | + | |
76 | +``` | |
77 | +Method Path Handler | |
78 | +GET / root | |
79 | +GET /items/{item_id} read_item | |
80 | +POST /items/ create_item | |
81 | +``` | |
82 | + | |
83 | +### `justapi doctor` | |
84 | + | |
85 | +Run system diagnostics. | |
86 | + | |
87 | +```bash | |
88 | +justapi doctor | |
89 | +``` | |
90 | + | |
91 | +Checks Python version, Rust availability, database connectivity, and configuration validity. | |
92 | + | |
93 | +### `justapi gen` | |
94 | + | |
95 | +Generate artifacts. | |
96 | + | |
97 | +```bash | |
98 | +justapi gen openapi > openapi.json # Generate OpenAPI spec | |
99 | +justapi gen client --lang typescript # Generate TypeScript client | |
100 | +``` | |
101 | + | |
102 | +### `justapi check` | |
103 | + | |
104 | +Validate configuration without starting the server. | |
105 | + | |
106 | +```bash | |
107 | +justapi check | |
108 | +``` | |
109 | + | |
110 | +### `justapi profile` | |
111 | + | |
112 | +Profile handler performance. | |
113 | + | |
114 | +```bash | |
115 | +justapi profile --endpoint /items/42 | |
116 | +``` | |
117 | + | |
118 | +### `justapi new` | |
119 | + | |
120 | +Alias for `justapi create`. | |
121 | + | |
122 | +## Global Flags | |
123 | + | |
124 | +| Flag | Description | | |
125 | +|---|---| | |
126 | +| `--help` | Show help message | | |
127 | +| `--version` | Show version | | |
128 | + | |
129 | +## See Also | |
130 | + | |
131 | +- [Configuration Reference](/reference/configuration/) — Environment variables and app config | |
132 | +- [Project Scaffolder](/getting-started/cli-scaffolder/) — Project generation guide | |
133 | +- [Release Notes](/reference/release-notes/) — Version history | |
0 | 134 | |
▼docs_site/src/content/docs/reference/configuration.md
+70-0
| @@ -0,0 +1,70 @@ | ||
1 | +--- | |
2 | +title: Configuration Reference | |
3 | +description: Environment variables, app settings, and server configuration options. | |
4 | +--- | |
5 | + | |
6 | +## Environment Variables | |
7 | + | |
8 | +| Variable | Default | Description | | |
9 | +|---|---|---| | |
10 | +| `RUST_LOG` | `info` | Log level (error, warn, info, debug, trace) | | |
11 | +| `OTEL_SERVICE_NAME` | `justapi` | Service name for OpenTelemetry | | |
12 | +| `OTEL_EXPORTER_OTLP_ENDPOINT` | — | OTLP collector endpoint | | |
13 | +| `DATABASE_URL` | — | Database connection string | | |
14 | +| `REDIS_URL` | — | Redis connection string | | |
15 | +| `JWT_SECRET` | — | JWT signing secret | | |
16 | + | |
17 | +## `JustAPIApp()` Constructor | |
18 | + | |
19 | +```python | |
20 | +app = JustAPIApp( | |
21 | + title="My API", # OpenAPI title | |
22 | + version="1.0.0", # OpenAPI version | |
23 | + description="...", # OpenAPI description | |
24 | +) | |
25 | +``` | |
26 | + | |
27 | +## `app.run()` Parameters | |
28 | + | |
29 | +```python | |
30 | +app.run( | |
31 | + addr="127.0.0.1:8000", # Bind address | |
32 | + max_body_size=52428800, # Max body size (50 MiB) | |
33 | +) | |
34 | +``` | |
35 | + | |
36 | +## Server CLI Flags | |
37 | + | |
38 | +```bash | |
39 | +justapi serve --host 0.0.0.0 --port 8080 --workers 4 --timeout 30 | |
40 | +``` | |
41 | + | |
42 | +| Flag | Env Variable | Default | Description | | |
43 | +|---|---|---|---| | |
44 | +| `--host` | `HOST` | `127.0.0.1` | Bind address | | |
45 | +| `--port` | `PORT` | `8000` | Bind port | | |
46 | +| `--workers` | — | CPU count | Worker processes | | |
47 | +| `--timeout` | — | `30` | Request timeout (seconds) | | |
48 | +| `--reload` | — | false | Hot-reload | | |
49 | +| `--unix` | — | — | Unix socket path | | |
50 | + | |
51 | +## Feature Flags (Cargo) | |
52 | + | |
53 | +```toml | |
54 | +# Cargo.toml features for justapi-core | |
55 | +[dependencies] | |
56 | +justapi-core = { features = [ | |
57 | + "tls", # TLS support via rustls | |
58 | + "ws", # WebSocket support | |
59 | + "compression", # Response compression | |
60 | + "opentelemetry", # OpenTelemetry tracing | |
61 | + "db", # Database support | |
62 | + "simd-json", # SIMD-accelerated JSON | |
63 | +] } | |
64 | +``` | |
65 | + | |
66 | +## See Also | |
67 | + | |
68 | +- [CLI Reference](/reference/cli/) — Command line options | |
69 | +- [Environment Variables](#) — Runtime configuration | |
70 | +- [Feature Flags](https://github.com/swadhinbiswas/JustAPI/blob/main/Cargo.toml) | |
0 | 71 | |