AppView in a box as a Vite plugin thing hatk.dev
at main 75 lines 1.4 kB view raw view rendered
1--- 2title: Preferences 3description: Store and retrieve per-user preferences. 4--- 5 6## `dev.hatk.getPreferences` 7 8Get all preferences for the authenticated user. 9 10- **Type:** Query (GET) 11- **Auth:** Required (session cookie or DPoP token) 12 13### Example 14 15```bash 16curl "http://127.0.0.1:3000/xrpc/dev.hatk.getPreferences" \ 17 -H "Authorization: DPoP <token>" 18``` 19 20```typescript 21import { callXrpc } from "$hatk/client"; 22 23const { preferences } = await callXrpc("dev.hatk.getPreferences"); 24``` 25 26### Response 27 28```json 29{ 30 "preferences": { 31 "theme": "dark", 32 "notifications": true 33 } 34} 35``` 36 37--- 38 39## `dev.hatk.putPreference` 40 41Set a single preference by key for the authenticated user. 42 43- **Type:** Procedure (POST) 44- **Auth:** Required (session cookie or DPoP token) 45 46### Input 47 48| Name | Type | Required | Description | 49| ------- | ------ | -------- | ---------------- | 50| `key` | string | Yes | Preference key | 51| `value` | any | Yes | Preference value | 52 53### Example 54 55```bash 56curl -X POST "http://127.0.0.1:3000/xrpc/dev.hatk.putPreference" \ 57 -H "Authorization: DPoP <token>" \ 58 -H "Content-Type: application/json" \ 59 -d '{"key":"theme","value":"dark"}' 60``` 61 62```typescript 63import { callXrpc } from "$hatk/client"; 64 65await callXrpc("dev.hatk.putPreference", { 66 key: "theme", 67 value: "dark", 68}); 69``` 70 71### Response 72 73```json 74{} 75```