Cleaned dead code and updated documents
This commit is contained in:
@@ -144,40 +144,33 @@ Frontend gets `useChatChannel({ room })`.
|
||||
|
||||
## Generate the frontend
|
||||
|
||||
The codegen is `mizan-generate` (in `protocol/mizan-generate/`). From your
|
||||
frontend project, point a config at the Django backend and run the CLI:
|
||||
The codegen is the `mizan-generate` Rust binary (source at
|
||||
`protocol/mizan-codegen/`; `protocol/mizan-generate/` is a thin npm
|
||||
launcher that dispatches to the platform binary). From your frontend
|
||||
project, point a `mizan.toml` at the Django backend and run the CLI:
|
||||
|
||||
```js
|
||||
// frontend/django.config.mjs
|
||||
import path from "path"
|
||||
import { fileURLToPath } from "url"
|
||||
```toml
|
||||
# frontend/mizan.toml
|
||||
output = "src/api"
|
||||
targets = ["react"]
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const root = path.resolve(__dirname, "..")
|
||||
[source.django]
|
||||
manage_path = "../backend/manage.py"
|
||||
command = ["uv", "run", "python"] # optional — defaults to ["python"]
|
||||
|
||||
export default {
|
||||
source: {
|
||||
django: {
|
||||
managePath: path.join(root, "backend/manage.py"),
|
||||
command: ["uv", "run", "python"],
|
||||
env: {
|
||||
PYTHONPATH: path.join(root, "backend"),
|
||||
DJANGO_SETTINGS_MODULE: "myproject.settings",
|
||||
},
|
||||
},
|
||||
},
|
||||
output: "src/api",
|
||||
}
|
||||
[source.django.env]
|
||||
PYTHONPATH = "../backend"
|
||||
DJANGO_SETTINGS_MODULE = "myproject.settings"
|
||||
```
|
||||
|
||||
```bash
|
||||
npx mizan-generate --config django.config.mjs
|
||||
mizan-generate --config mizan.toml
|
||||
```
|
||||
|
||||
The codegen drives Django's management command (`export_mizan_schema`) under
|
||||
the hood, then emits Stage 1 (typed `callXxx`/`fetchXxx` over the runtime
|
||||
kernel) + Stage 2 (`<MizanContext>` provider, per-context providers,
|
||||
`use{Hook}()` hooks) into `src/api/`.
|
||||
The codegen drives Django's management command (`export_mizan_ir`) under
|
||||
the hood, parses the emitted KDL IR, then emits Stage 1 (typed
|
||||
`callXxx`/`fetchXxx` over the runtime kernel) + Stage 2 (`<MizanContext>`
|
||||
provider, per-context providers, `use{Hook}()` hooks) into `src/api/`.
|
||||
|
||||
```tsx
|
||||
// app.tsx
|
||||
|
||||
Reference in New Issue
Block a user