@donkeylabs/server 1.1.12 → 1.1.13

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 (2) hide show
  1. package/docs/QUICKSTART.md +149 -0
  2. package/package.json +1 -1
@@ -0,0 +1,149 @@
1
+ # Quick Start Guide
2
+
3
+ Get from zero to a working API in 5 minutes.
4
+
5
+ ## 1. Create a Project
6
+
7
+ ```bash
8
+ bunx @donkeylabs/cli init my-app
9
+ cd my-app
10
+ bun install
11
+ ```
12
+
13
+ Choose **sveltekit-app** for full-stack or **starter** for API-only.
14
+
15
+ ## 2. Start Development Server
16
+
17
+ ```bash
18
+ bun run dev
19
+ ```
20
+
21
+ Your server is now running. The API client is auto-generated at `src/lib/api.ts`.
22
+
23
+ ## 3. Create Your First Feature
24
+
25
+ Using Claude Code with the MCP server:
26
+
27
+ ```
28
+ scaffold_feature
29
+ name: "todos"
30
+ crud: true
31
+ fields: "title: string, completed: boolean"
32
+ ```
33
+
34
+ This creates:
35
+ ```
36
+ src/server/routes/todos/
37
+ ├── index.ts # Router
38
+ ├── todos.schemas.ts # Zod schemas
39
+ ├── handlers/
40
+ │ ├── create.handler.ts
41
+ │ ├── list.handler.ts
42
+ │ ├── get.handler.ts
43
+ │ ├── update.handler.ts
44
+ │ └── delete.handler.ts
45
+ └── todos.test.ts
46
+ ```
47
+
48
+ ## 4. Add Database Table
49
+
50
+ Create a plugin with a migration:
51
+
52
+ ```
53
+ create_plugin
54
+ name: "todos"
55
+ hasSchema: true
56
+ ```
57
+
58
+ ```
59
+ add_migration
60
+ pluginName: "todos"
61
+ migrationName: "create_todos"
62
+ upCode: 'await db.schema.createTable("todos").addColumn("id", "text", (col) => col.primaryKey()).addColumn("title", "text", (col) => col.notNull()).addColumn("completed", "integer", (col) => col.notNull().defaultTo(0)).addColumn("created_at", "text", (col) => col.notNull()).addColumn("updated_at", "text", (col) => col.notNull()).execute();'
63
+ ```
64
+
65
+ ## 5. Register Everything
66
+
67
+ In `src/server/index.ts`:
68
+
69
+ ```typescript
70
+ import { todosPlugin } from "./plugins/todos";
71
+ import { todosRouter } from "./routes/todos";
72
+
73
+ server.registerPlugin(todosPlugin);
74
+ server.use(todosRouter);
75
+ ```
76
+
77
+ ## 6. Generate Types
78
+
79
+ ```bash
80
+ bunx donkeylabs generate
81
+ ```
82
+
83
+ ## 7. Use the API
84
+
85
+ **In +page.server.ts (SSR - no HTTP overhead):**
86
+ ```typescript
87
+ import { createApi } from "$lib/api";
88
+
89
+ export const load = async ({ locals }) => {
90
+ const api = createApi({ locals });
91
+ const todos = await api.todos.list({});
92
+ return { todos };
93
+ };
94
+ ```
95
+
96
+ **In +page.svelte (browser):**
97
+ ```svelte
98
+ <script lang="ts">
99
+ import { createApi } from "$lib/api";
100
+
101
+ const api = createApi();
102
+ let { data } = $props();
103
+
104
+ async function addTodo(title: string) {
105
+ await api.todos.create({ title, completed: false });
106
+ }
107
+ </script>
108
+ ```
109
+
110
+ ## Next Steps
111
+
112
+ - **Add authentication**: See `get_architecture_guidance` with task "add auth"
113
+ - **Add real-time updates**: Use SSE routes with `add_sse_route`
114
+ - **Add background jobs**: Use `add_async_job` for email, processing, etc.
115
+ - **Read the docs**: `donkeylabs://docs/plugins`, `donkeylabs://docs/handlers`
116
+
117
+ ## Key Commands
118
+
119
+ | Command | Description |
120
+ |---------|-------------|
121
+ | `bun run dev` | Start dev server |
122
+ | `bunx donkeylabs generate` | Regenerate types |
123
+ | `bun test` | Run tests |
124
+ | `bun --bun tsc --noEmit` | Type check |
125
+
126
+ ## MCP Tools Reference
127
+
128
+ | Tool | Use For |
129
+ |------|---------|
130
+ | `scaffold_feature` | Create complete feature module with handlers |
131
+ | `create_plugin` | Create reusable business logic plugin |
132
+ | `add_migration` | Add database schema changes |
133
+ | `add_route` | Add route to existing router |
134
+ | `generate_types` | Regenerate TypeScript types |
135
+
136
+ ## Troubleshooting
137
+
138
+ **Types not updating?**
139
+ ```bash
140
+ bunx donkeylabs generate
141
+ ```
142
+
143
+ **Migration errors?**
144
+ - Use Kysely schema builder, never raw SQL
145
+ - Check migration file numbering (001_, 002_, etc.)
146
+
147
+ **Route not found?**
148
+ - Register the router with `server.use(router)`
149
+ - Run `bunx donkeylabs generate`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donkeylabs/server",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "description": "Type-safe plugin system for building RPC-style APIs with Bun",
6
6
  "main": "./src/index.ts",