create-apexjs 0.6.6 → 0.6.7
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.
package/package.json
CHANGED
|
@@ -21,8 +21,8 @@ apex make page dashboard # pages/dashboard.alpine (a route → /dashboa
|
|
|
21
21
|
apex make component Card # components/Card.alpine (<Card /> in templates)
|
|
22
22
|
apex make component ui/Navbar # group in a folder → components/ui/Navbar.alpine (<UiNavbar />)
|
|
23
23
|
apex make client # app.client.ts — register Alpine plugins/directives/magics
|
|
24
|
-
apex make model
|
|
25
|
-
apex make composable
|
|
24
|
+
apex make model Article title:string body:string # models/Article.ts → defineModel('articles') → /api/articles + MCP CRUD (avoid `Post` — the starter ships a posts demo)
|
|
25
|
+
apex make composable Article # composables/useArticles.ts — typed client data-hook off the model (make the model first)
|
|
26
26
|
apex make api webhooks # server/api/webhooks.ts (defineApexRoute; also an MCP tool)
|
|
27
27
|
apex make service Billing # services/BillingService.ts
|
|
28
28
|
apex extend auth # add sealed-cookie sessions + login/logout + /account
|
|
@@ -36,12 +36,12 @@ apex test # run Vitest
|
|
|
36
36
|
```
|
|
37
37
|
`apex make <kind> …` kinds: `page component api service store layout middleware test model migration auth client composable`.
|
|
38
38
|
|
|
39
|
-
**Data flow, end to end.** One `defineModel` drives the whole stack: schema + migration + REST (`/api/
|
|
39
|
+
**Data flow, end to end.** One `defineModel` drives the whole stack: schema + migration + REST (`/api/articles` list/get/create/update/delete) + MCP tools **and** the client. `apex make composable Article` emits `composables/useArticles.ts` — a typed `useArticles()` returning `items / loading / error` + `fetch / find / create / update / remove` bound to that resource. Spread it into an x-data:
|
|
40
40
|
```alpine
|
|
41
41
|
<script client>
|
|
42
|
-
import {
|
|
42
|
+
import { useArticles } from '../composables/useArticles'
|
|
43
43
|
</script>
|
|
44
|
-
<template x-data="{ ...
|
|
44
|
+
<template x-data="{ ...useArticles(), init() { this.fetch() } }">
|
|
45
45
|
<template x-for="p in items" :key="p.id"><li x-text="p.title"></li></template>
|
|
46
46
|
</template>
|
|
47
47
|
```
|
|
@@ -87,7 +87,7 @@ tests/*.test.ts Vitest. createTestApp boots the whole app in-process.
|
|
|
87
87
|
|
|
88
88
|
## APIs you'll use (import from `@apex-stack/core`, `/server`, `/testing`; data from `@apex-stack/data`)
|
|
89
89
|
- **Route** → `defineApexRoute({ method, input: { …zod }, mcp: true, auth: true, can, handler })`. `mcp: true` makes it an AI-callable tool at `/mcp`.
|
|
90
|
-
- **Model** → `defineModel('
|
|
90
|
+
- **Model** → `defineModel('articles', { fields: {…}, use: [timestamps(), owned()] })` → `.resource(handle)` mounts REST + MCP CRUD. Its route imports `@apex-stack/data`, so install it (`npm i @apex-stack/data @libsql/client`) — otherwise `createTestApp` can't mount `/api` and every API test errors (or pass `createTestApp({ root, lenientRoutes: true })` to skip unresolvable routes).
|
|
91
91
|
- **Auth** → `server/auth.ts` default-exports `sessionAuth({ password })`; gate routes with `auth: true` / `can`. In loaders, the user is `locals.user`.
|
|
92
92
|
- **Config** → `apex.config.ts`: `defineConfig({ runtimeConfig: { …, public: {…} }, i18n: {…} })`. Read with `useRuntimeConfig()`.
|
|
93
93
|
- **Test** → `createTestApp({ root })` → `app.get/post(path, body?, { user })`, `app.mcp.listTools()`.
|