create-wervt 0.2.18 → 0.2.20

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/index.js CHANGED
@@ -42,7 +42,7 @@ const EMPTY_SCHEMA = `// Tables are declared without a schema: on wervt the app'
42
42
  // })
43
43
  export {}
44
44
  `
45
- const EMPTY_APP = `<template>
45
+ const EMPTY_PAGE = `<template>
46
46
  <main>
47
47
  <h1>Hello from wervt</h1>
48
48
  </main>
@@ -134,7 +134,7 @@ const main = defineCommand({
134
134
  if (args.empty) {
135
135
  for (const file of EXAMPLE_FILES) await rm(join(dir, file), { recursive: true, force: true })
136
136
  await writeFile(join(dir, 'server/db/schema.ts'), EMPTY_SCHEMA)
137
- await writeFile(join(dir, 'app.vue'), EMPTY_APP)
137
+ await writeFile(join(dir, 'pages/index.vue'), EMPTY_PAGE)
138
138
  }
139
139
 
140
140
  const pkgPath = join(dir, 'package.json')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wervt",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "Create a new wervt app: Nuxt 5, Postgres with Drizzle, live data with Electric.",
5
5
  "homepage": "https://wervt.app",
6
6
  "license": "MIT",
@@ -6,7 +6,8 @@ Supabase Edge Runtime) with its own Postgres schema and live data through Electr
6
6
 
7
7
  ## Layout
8
8
 
9
- - `app.vue`, `pages/`, `components/`: the Vue app.
9
+ - `pages/`: one route per file, `pages/index.vue` is `/`. `app.vue` is the shell around every page
10
+ (`<NuxtPage />`, wrapped in `<UApp>` with Nuxt UI). `components/`: the Vue components.
10
11
  - `server/api/`: API routes. `server/api/shapes/`: live data routes.
11
12
  - `server/tools/`: tools that AI agents can call: in the browser (WebMCP) and at `/mcp` (MCP).
12
13
  API routes become tools with `defineToolRoute`.
@@ -118,6 +119,9 @@ const rows = await useDb().select().from(todos).where(eq(todos.done, false))
118
119
  - For relational queries (`db.query.rooms.findFirst({ with: … })`), define relations with
119
120
  `defineRelations` in `server/db/relations.ts` and use `useDb({ relations })`.
120
121
  - No raw SQL against other schemas, `public`, or system catalogs: the role can't access them.
122
+ - `vector` (pgvector: `vector({ dimensions })` columns, `cosineDistance`), `pg_trgm`, `unaccent`
123
+ and `citext` are installed for every app. Use their types and functions unqualified; never write
124
+ `CREATE EXTENSION` into a migration.
121
125
 
122
126
  ### Seeding
123
127
 
@@ -186,6 +190,9 @@ version polling. For a banner in the app's own design, set `wervt: { updates: 'm
186
190
  auto-imported) give the signed-in wervt user or nothing. Private apps always have one; public
187
191
  apps only when the visitor signed in. It works with `ssr: false` too (no own `/api/me` needed). Link to `wervtLoginUrl(path)` / `wervtLogoutUrl(path)` as
188
192
  external links. Never build your own login or OAuth.
193
+ - Name, picture and email change on wervt's account page: link to `wervtAccountUrl(path)`
194
+ (external), which shows it in the app's look and comes back. Don't build forms that change
195
+ them; keep app-only profile data (bio, display name) in the app's tables under `user.id`.
189
196
  - Users are one row per wervt account: key them by `user.id`, not by email (addresses change).
190
197
  When an admin merges two accounts of the same person, wervt runs the task
191
198
  `wervt:account-merged` (`server/tasks/wervt/account-merged.ts`) with
@@ -220,6 +227,11 @@ own bucket and `@wervt/nuxt` connects it; don't configure a provider or S3 crede
220
227
  three routes plus `useDirectUpload()` on the page, so browsers upload straight to the bucket;
221
228
  serve them with `signedUrl(file)`, a presigned link to the bucket.
222
229
  - No tus uploads and no `transform` / sharp: they need a disk and native modules.
230
+ - Images: never resize in the app. `imageUrl(file, { width: 800 })` from `@wervt/nuxt/server`
231
+ returns a URL on the app's own host where wervt serves that size (`fit: 'fill'`, `gravity`,
232
+ `crop`, `rotate`, `format`, `quality`, `keepMetadata`, `download`, `expiresIn`); HEIC works as a
233
+ source. Build the URLs in a route after checking access: whoever has one can load that image.
234
+ `fetchImage(file, options)` loads such a version on the server (pixels, a converted copy).
223
235
  - Check access in the route before serving a file.
224
236
 
225
237
  ## Real-world things
package/template/app.vue CHANGED
@@ -1,37 +1,3 @@
1
- <script setup lang="ts">
2
- import type { Todo } from './server/db/schema'
3
-
4
- // Rows arrive with SSR and then stay live: every write below shows up here (and in every
5
- // other open tab) through Electric, so there is nothing to refetch.
6
- const { data, isLive } = await useShape('/api/shapes/todos')
7
- const todos = computed(() => data.value.toSorted((a, b) => a.id - b.id))
8
- const title = ref('')
9
-
10
- async function add() {
11
- await $fetch('/api/todos', { method: 'POST', body: { title: title.value } })
12
- title.value = ''
13
- }
14
- const toggle = (todo: Todo) =>
15
- $fetch(`/api/todos/${todo.id}`, { method: 'PATCH', body: { done: !todo.done } })
16
- const remove = (todo: Todo) => $fetch(`/api/todos/${todo.id}`, { method: 'DELETE' })
17
- </script>
18
-
19
1
  <template>
20
- <main>
21
- <h1>Todos</h1>
22
- <p>{{ isLive ? 'Live' : 'Connecting…' }}</p>
23
- <form @submit.prevent="add">
24
- <input v-model="title" placeholder="What needs doing?" required />
25
- <button>Add</button>
26
- </form>
27
- <ul>
28
- <li v-for="todo in todos" :key="todo.id">
29
- <label>
30
- <input type="checkbox" :checked="todo.done" @change="toggle(todo)" />
31
- {{ todo.title }}
32
- </label>
33
- <button @click="remove(todo)">Delete</button>
34
- </li>
35
- </ul>
36
- </main>
2
+ <NuxtPage />
37
3
  </template>
@@ -10,15 +10,16 @@
10
10
  "postinstall": "nuxt prepare"
11
11
  },
12
12
  "dependencies": {
13
- "@wervt/nuxt": "^0.3.11",
13
+ "@wervt/nuxt": "^0.3.21",
14
14
  "drizzle-orm": "1.0.0-rc.5",
15
15
  "nuxt": "npm:nuxt-nightly@5x",
16
16
  "valibot": "^1.5.0",
17
- "vue": "^3.5.44"
17
+ "vue": "^3.5.45",
18
+ "vue-router": "^5.5.1"
18
19
  },
19
20
  "devDependencies": {
20
21
  "@golar/vue": "^0.1.11",
21
- "@wervt/cli": "^0.2.19",
22
+ "@wervt/cli": "^0.2.28",
22
23
  "drizzle-kit": "1.0.0-rc.5",
23
24
  "golar": "^0.1.11",
24
25
  "vite-plus": "^1.3.0"
@@ -0,0 +1,37 @@
1
+ <script setup lang="ts">
2
+ import type { Todo } from '../server/db/schema'
3
+
4
+ // Rows arrive with SSR and then stay live: every write below shows up here (and in every
5
+ // other open tab) through Electric, so there is nothing to refetch.
6
+ const { data, isLive } = await useShape('/api/shapes/todos')
7
+ const todos = computed(() => data.value.toSorted((a, b) => a.id - b.id))
8
+ const title = ref('')
9
+
10
+ async function add() {
11
+ await $fetch('/api/todos', { method: 'POST', body: { title: title.value } })
12
+ title.value = ''
13
+ }
14
+ const toggle = (todo: Todo) =>
15
+ $fetch(`/api/todos/${todo.id}`, { method: 'PATCH', body: { done: !todo.done } })
16
+ const remove = (todo: Todo) => $fetch(`/api/todos/${todo.id}`, { method: 'DELETE' })
17
+ </script>
18
+
19
+ <template>
20
+ <main>
21
+ <h1>Todos</h1>
22
+ <p>{{ isLive ? 'Live' : 'Connecting…' }}</p>
23
+ <form @submit.prevent="add">
24
+ <input v-model="title" placeholder="What needs doing?" required />
25
+ <button>Add</button>
26
+ </form>
27
+ <ul>
28
+ <li v-for="todo in todos" :key="todo.id">
29
+ <label>
30
+ <input type="checkbox" :checked="todo.done" @change="toggle(todo)" />
31
+ {{ todo.title }}
32
+ </label>
33
+ <button @click="remove(todo)">Delete</button>
34
+ </li>
35
+ </ul>
36
+ </main>
37
+ </template>
@@ -6,3 +6,7 @@ allowBuilds:
6
6
  minimumReleaseAgeExclude:
7
7
  # wervt's own packages, so a new app gets the release that was just published.
8
8
  - '@wervt/*'
9
+ overrides:
10
+ # A module names `nuxt` as its peer. A package manager that does not take the aliased nightly
11
+ # for it installs stable Nuxt next to it, and its devtools with it.
12
+ nuxt: npm:nuxt-nightly@5x