create-kerf 0.0.0-stage → 0.1.0

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 (128) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +401 -2
  3. package/bin/create-kerf.mjs +121 -0
  4. package/package.json +37 -3
  5. package/scripts/tarballs.mjs +77 -0
  6. package/src/data.mjs +360 -0
  7. package/src/index.mjs +400 -0
  8. package/src/stack/pages.mjs +151 -0
  9. package/src/stack/schema.mjs +195 -0
  10. package/src/stack.mjs +293 -0
  11. package/src/templates.mjs +175 -0
  12. package/src/wizard.mjs +127 -0
  13. package/templates/admin/files/drizzle/.schema-hash +1 -0
  14. package/templates/admin/files/drizzle/0000_admin.sql +136 -0
  15. package/templates/admin/files/drizzle/meta/0000_snapshot.json +771 -0
  16. package/templates/admin/files/drizzle/meta/_journal.json +13 -0
  17. package/templates/admin/files/kerf.config.ts +31 -0
  18. package/templates/admin/files/public/favicon.svg +1 -0
  19. package/templates/admin/files/src/auth.server.ts +24 -0
  20. package/templates/admin/files/src/components/AuthPage.tsx +33 -0
  21. package/templates/admin/files/src/components/Failed.tsx +19 -0
  22. package/templates/admin/files/src/components/Logo.tsx +16 -0
  23. package/templates/admin/files/src/components/OrderDetail.tsx +93 -0
  24. package/templates/admin/files/src/components/OrdersFilters.tsx +44 -0
  25. package/templates/admin/files/src/components/OrdersTable.tsx +144 -0
  26. package/templates/admin/files/src/components/Overview.tsx +113 -0
  27. package/templates/admin/files/src/components/StatusBadge.tsx +12 -0
  28. package/templates/admin/files/src/db/schema.ts +68 -0
  29. package/templates/admin/files/src/lib/orders.ts +60 -0
  30. package/templates/admin/files/src/routes/404.tsx +20 -0
  31. package/templates/admin/files/src/routes/_error.tsx +20 -0
  32. package/templates/admin/files/src/routes/_layout.tsx +6 -0
  33. package/templates/admin/files/src/routes/admin/_layout.tsx +89 -0
  34. package/templates/admin/files/src/routes/admin/index.tsx +45 -0
  35. package/templates/admin/files/src/routes/admin/nested/_layout.tsx +35 -0
  36. package/templates/admin/files/src/routes/admin/nested/index.tsx +77 -0
  37. package/templates/admin/files/src/routes/admin/orders/[id].tsx +24 -0
  38. package/templates/admin/files/src/routes/admin/orders/index.tsx +28 -0
  39. package/templates/admin/files/src/routes/admin/per-row.tsx +81 -0
  40. package/templates/admin/files/src/routes/admin/slow.tsx +74 -0
  41. package/templates/admin/files/src/routes/index.tsx +13 -0
  42. package/templates/admin/files/src/routes/login.tsx +53 -0
  43. package/templates/admin/files/src/routes/signup.tsx +60 -0
  44. package/templates/admin/files/src/server/orders.ts +193 -0
  45. package/templates/admin/files/src/server/reports.ts +92 -0
  46. package/templates/admin/files/src/server/session.ts +45 -0
  47. package/templates/admin/files/src/theme.css +43 -0
  48. package/templates/admin/template.json +22 -0
  49. package/templates/catalog/files/drizzle/.schema-hash +1 -0
  50. package/templates/catalog/files/drizzle/0000_catalog.sql +47 -0
  51. package/templates/catalog/files/drizzle/meta/0000_snapshot.json +263 -0
  52. package/templates/catalog/files/drizzle/meta/_journal.json +13 -0
  53. package/templates/catalog/files/kerf.config.ts +30 -0
  54. package/templates/catalog/files/public/favicon.svg +1 -0
  55. package/templates/catalog/files/seed.sql +13 -0
  56. package/templates/catalog/files/src/components/AddToCart.tsx +22 -0
  57. package/templates/catalog/files/src/components/Aisles.tsx +31 -0
  58. package/templates/catalog/files/src/components/CartLines.tsx +96 -0
  59. package/templates/catalog/files/src/components/CartLink.tsx +29 -0
  60. package/templates/catalog/files/src/components/Failed.tsx +19 -0
  61. package/templates/catalog/files/src/components/Featured.tsx +19 -0
  62. package/templates/catalog/files/src/components/Filters.tsx +40 -0
  63. package/templates/catalog/files/src/components/Logo.tsx +16 -0
  64. package/templates/catalog/files/src/components/ProductArt.tsx +42 -0
  65. package/templates/catalog/files/src/components/ProductCard.tsx +42 -0
  66. package/templates/catalog/files/src/components/ProductList.tsx +65 -0
  67. package/templates/catalog/files/src/components/Related.tsx +19 -0
  68. package/templates/catalog/files/src/components/SiteFooter.tsx +9 -0
  69. package/templates/catalog/files/src/components/SiteHeader.tsx +16 -0
  70. package/templates/catalog/files/src/db/schema.ts +53 -0
  71. package/templates/catalog/files/src/lib/catalog.ts +35 -0
  72. package/templates/catalog/files/src/routes/404.tsx +18 -0
  73. package/templates/catalog/files/src/routes/_error.tsx +18 -0
  74. package/templates/catalog/files/src/routes/_layout.tsx +14 -0
  75. package/templates/catalog/files/src/routes/c/[slug].tsx +53 -0
  76. package/templates/catalog/files/src/routes/cart.tsx +29 -0
  77. package/templates/catalog/files/src/routes/index.tsx +84 -0
  78. package/templates/catalog/files/src/routes/p/[slug].tsx +67 -0
  79. package/templates/catalog/files/src/server/cart.ts +125 -0
  80. package/templates/catalog/files/src/server/catalog.ts +107 -0
  81. package/templates/catalog/files/src/theme.css +159 -0
  82. package/templates/catalog/template.json +20 -0
  83. package/templates/landing/files/.kerf/plugins.lock.json +42 -0
  84. package/templates/landing/files/assets/fonts/LICENSE-figtree.txt +93 -0
  85. package/templates/landing/files/assets/fonts/figtree.woff2 +0 -0
  86. package/templates/landing/files/assets/hero.webp +0 -0
  87. package/templates/landing/files/drizzle/.schema-hash +1 -0
  88. package/templates/landing/files/drizzle/0000_landing.sql +6 -0
  89. package/templates/landing/files/drizzle/meta/0000_snapshot.json +60 -0
  90. package/templates/landing/files/drizzle/meta/_journal.json +13 -0
  91. package/templates/landing/files/kerf.config.ts +44 -0
  92. package/templates/landing/files/public/favicon.svg +1 -0
  93. package/templates/landing/files/src/components/SiteFooter.tsx +24 -0
  94. package/templates/landing/files/src/components/SiteHeader.tsx +23 -0
  95. package/templates/landing/files/src/components/WaitlistForm.tsx +36 -0
  96. package/templates/landing/files/src/db/schema.ts +7 -0
  97. package/templates/landing/files/src/routes/404.tsx +24 -0
  98. package/templates/landing/files/src/routes/_error.tsx +24 -0
  99. package/templates/landing/files/src/routes/_layout.tsx +14 -0
  100. package/templates/landing/files/src/routes/index.tsx +130 -0
  101. package/templates/landing/files/src/routes/joined.tsx +30 -0
  102. package/templates/landing/files/src/routes/pricing.tsx +131 -0
  103. package/templates/landing/files/src/routes/privacy.tsx +56 -0
  104. package/templates/landing/files/src/server/waitlist.ts +13 -0
  105. package/templates/landing/files/src/theme.css +108 -0
  106. package/templates/landing/template.json +17 -0
  107. package/templates/todo/files/drizzle/.schema-hash +1 -0
  108. package/templates/todo/files/drizzle/0000_todo.sql +82 -0
  109. package/templates/todo/files/drizzle/meta/0000_snapshot.json +462 -0
  110. package/templates/todo/files/drizzle/meta/_journal.json +13 -0
  111. package/templates/todo/files/kerf.config.ts +30 -0
  112. package/templates/todo/files/public/favicon.svg +1 -0
  113. package/templates/todo/files/src/components/AuthPage.tsx +33 -0
  114. package/templates/todo/files/src/components/Logo.tsx +14 -0
  115. package/templates/todo/files/src/components/NewTodo.tsx +27 -0
  116. package/templates/todo/files/src/components/TodoList.tsx +101 -0
  117. package/templates/todo/files/src/db/schema.ts +18 -0
  118. package/templates/todo/files/src/lib/views.ts +13 -0
  119. package/templates/todo/files/src/routes/404.tsx +20 -0
  120. package/templates/todo/files/src/routes/_error.tsx +20 -0
  121. package/templates/todo/files/src/routes/_layout.tsx +6 -0
  122. package/templates/todo/files/src/routes/index.tsx +13 -0
  123. package/templates/todo/files/src/routes/login.tsx +53 -0
  124. package/templates/todo/files/src/routes/signup.tsx +57 -0
  125. package/templates/todo/files/src/routes/todos.tsx +87 -0
  126. package/templates/todo/files/src/server/todos.ts +98 -0
  127. package/templates/todo/files/src/theme.css +71 -0
  128. package/templates/todo/template.json +18 -0
package/src/data.mjs ADDED
@@ -0,0 +1,360 @@
1
+ // The Native and Prisma data layers of a scaffold, beside Drizzle's in stack.mjs. Each writes the same
2
+ // todo app, so the same e2e holds for every layer. `kerf add db` writes these files too.
3
+
4
+ const engineSql = {
5
+ sqlite: { bool: 'integer not null default 0', big: 'integer' },
6
+ postgres: { bool: 'boolean not null default false', big: 'bigint' },
7
+ mysql: { bool: 'boolean not null default false', big: 'bigint' },
8
+ }
9
+
10
+ // Better Auth's tables under its default names, which are camelCase, so they're quoted. MySQL can't key a TEXT column.
11
+ export function nativeAuthSql(db) {
12
+ const q = (name) => (db === 'mysql' ? `\`${name}\`` : `"${name}"`)
13
+ const key = 'varchar(255)'
14
+ const text = 'text'
15
+ const when = { sqlite: 'date', postgres: 'timestamptz', mysql: 'datetime(3)' }[db]
16
+ const bool = { sqlite: 'integer', postgres: 'boolean', mysql: 'boolean' }[db]
17
+ const table = (name, columns) =>
18
+ `create table ${q(name)} (\n${columns.map(([c, type]) => ` ${q(c)} ${type}`).join(',\n')}\n);\n`
19
+ const ref = (to) => `references ${q(to)} (${q('id')}) on delete cascade`
20
+ const stamps = [
21
+ ['createdAt', `${when} not null`],
22
+ ['updatedAt', `${when} not null`],
23
+ ]
24
+ return [
25
+ table('user', [
26
+ ['id', `${key} primary key`],
27
+ ['name', `${text} not null`],
28
+ ['email', `${key} not null unique`],
29
+ ['emailVerified', `${bool} not null`],
30
+ ['image', text],
31
+ ...stamps,
32
+ ]),
33
+ table('session', [
34
+ ['id', `${key} primary key`],
35
+ ['expiresAt', `${when} not null`],
36
+ ['token', `${key} not null unique`],
37
+ ...stamps,
38
+ ['ipAddress', text],
39
+ ['userAgent', text],
40
+ ['userId', `${key} not null ${ref('user')}`],
41
+ ]),
42
+ table('account', [
43
+ ['id', `${key} primary key`],
44
+ ['accountId', `${text} not null`],
45
+ ['providerId', `${text} not null`],
46
+ ['userId', `${key} not null ${ref('user')}`],
47
+ ['accessToken', text],
48
+ ['refreshToken', text],
49
+ ['idToken', text],
50
+ ['accessTokenExpiresAt', when],
51
+ ['refreshTokenExpiresAt', when],
52
+ ['scope', text],
53
+ ['password', text],
54
+ ...stamps,
55
+ ]),
56
+ table('verification', [
57
+ ['id', `${key} primary key`],
58
+ ['identifier', `${text} not null`],
59
+ ['value', `${text} not null`],
60
+ ['expiresAt', `${when} not null`],
61
+ ['createdAt', when],
62
+ ['updatedAt', when],
63
+ ]),
64
+ table('jwks', [
65
+ ['id', `${key} primary key`],
66
+ ['publicKey', `${text} not null`],
67
+ ['privateKey', `${text} not null`],
68
+ ['createdAt', `${when} not null`],
69
+ ['expiresAt', when],
70
+ ['alg', text],
71
+ ['crv', text],
72
+ ]),
73
+ ].join('\n')
74
+ }
75
+
76
+ const nativeTodos = (auth) => {
77
+ const use = auth ? `\n auth: 'user',` : ''
78
+ const mine = auth ? ` and user_id = \${ctx.user.id}` : ''
79
+ return `import { mutation, query } from '@kerf-js/start'
80
+ import { z } from 'zod'
81
+
82
+ interface Todo { id: string; title: string; done: boolean }
83
+ const byId = z.object({ id: z.string() })
84
+
85
+ export const listTodos = query({
86
+ tags: ['todos'],${use}
87
+ run: async ({ ctx }) => {
88
+ const rows = await ctx.db.sql\`select id, title, done from todos${auth ? ` where user_id = \${ctx.user.id}` : ''} order by created_at\`
89
+ return (rows as unknown as Todo[]).map(t => ({ ...t, done: Boolean(t.done) }))
90
+ },
91
+ })
92
+
93
+ export const addTodo = mutation({
94
+ input: z.object({ title: z.string().trim().min(1).max(200) }),${use}
95
+ invalidates: ['todos'],
96
+ optimistic: ({ input }, cache) =>
97
+ cache.update(listTodos, undefined, list => void list.push({ id: \`tmp:\${input.title}\`, title: input.title, done: false })),
98
+ run: async ({ input, ctx }) => {
99
+ await ctx.db.sql\`insert into todos (id, title, done, created_at${auth ? ', user_id' : ''}) values (\${crypto.randomUUID()}, \${input.title}, \${false}, \${Date.now()}${auth ? `, \${ctx.user.id}` : ''})\`
100
+ },
101
+ })
102
+
103
+ export const toggleTodo = mutation({
104
+ input: byId,${use}
105
+ invalidates: ['todos'],
106
+ optimistic: ({ input }, cache) =>
107
+ cache.update(listTodos, undefined, list => {
108
+ const t = list.find(x => x.id === input.id)
109
+ if (t) t.done = !t.done
110
+ }),
111
+ run: async ({ input, ctx }) => {
112
+ await ctx.db.sql\`update todos set done = not done where id = \${input.id}${mine}\`
113
+ },
114
+ })
115
+
116
+ export const deleteTodo = mutation({
117
+ input: byId,${use}
118
+ invalidates: ['todos'],
119
+ optimistic: ({ input }, cache) => cache.update(listTodos, undefined, list => list.filter(x => x.id !== input.id)),
120
+ run: async ({ input, ctx }) => {
121
+ await ctx.db.sql\`delete from todos where id = \${input.id}${mine}\`
122
+ },
123
+ })
124
+ `
125
+ }
126
+
127
+ export const nativeFiles = ({ db, auth }) => ({
128
+ 'migrations/0000_todos.sql': `${auth ? `${nativeAuthSql(db)}\n` : ''}create table todos (
129
+ id varchar(36) primary key,
130
+ title varchar(200) not null,
131
+ done ${engineSql[db].bool},
132
+ created_at ${engineSql[db].big} not null${auth ? `,\n user_id varchar(255) not null references ${db === 'mysql' ? '`user`' : '"user"'} (id) on delete cascade` : ''}
133
+ );
134
+ `,
135
+ 'src/db/index.server.ts': `import { createDb } from '@kerf-js/db/plugin-native/${db}'
136
+ import { env } from '../env.server'
137
+
138
+ export const db = createDb({ url: env.DATABASE_URL })
139
+ `,
140
+ ...(auth && {
141
+ 'src/auth.server.ts': `import { createAuth } from '@kerf-js/start/auth/better-auth'
142
+ import { nativeAuth } from '@kerf-js/db/plugin-native/auth'
143
+ import { db } from '#/db/index.server'
144
+ import { env } from './env.server'
145
+
146
+ export default createAuth({ db, secret: env.BETTER_AUTH_SECRET, options: { database: nativeAuth(db) } })
147
+ `,
148
+ }),
149
+ 'src/server/todos.ts': nativeTodos(auth),
150
+ })
151
+
152
+ const PROVIDER = { sqlite: 'sqlite', postgres: 'postgresql', mysql: 'mysql' }
153
+ const ADAPTER = {
154
+ sqlite: {
155
+ pkg: '@prisma/adapter-libsql',
156
+ name: 'PrismaLibSql',
157
+ make: '{ url: env.DATABASE_URL }',
158
+ },
159
+ postgres: {
160
+ pkg: '@prisma/adapter-pg',
161
+ name: 'PrismaPg',
162
+ make: '{ connectionString: env.DATABASE_URL }',
163
+ },
164
+ mysql: { pkg: '@prisma/adapter-mariadb', name: 'PrismaMariaDb', make: 'env.DATABASE_URL' },
165
+ }
166
+ export const prismaAdapterPackage = (db) => ADAPTER[db].pkg
167
+
168
+ const authModels = (db) => {
169
+ const long = db === 'mysql' ? ' @db.Text' : ''
170
+ return `
171
+ // Better Auth's tables: it reads and writes them through Prisma, with these names.
172
+ model User {
173
+ id String @id
174
+ name String
175
+ email String @unique
176
+ emailVerified Boolean @map("email_verified")
177
+ image String?${long}
178
+ createdAt DateTime @map("created_at")
179
+ updatedAt DateTime @map("updated_at")
180
+ sessions Session[]
181
+ accounts Account[]
182
+ todos Todo[]
183
+
184
+ @@map("user")
185
+ }
186
+
187
+ model Session {
188
+ id String @id
189
+ expiresAt DateTime @map("expires_at")
190
+ token String @unique
191
+ createdAt DateTime @map("created_at")
192
+ updatedAt DateTime @map("updated_at")
193
+ ipAddress String? @map("ip_address")
194
+ userAgent String? @map("user_agent")${long}
195
+ userId String @map("user_id")
196
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
197
+
198
+ @@map("session")
199
+ }
200
+
201
+ model Account {
202
+ id String @id
203
+ accountId String @map("account_id")
204
+ providerId String @map("provider_id")
205
+ userId String @map("user_id")
206
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
207
+ accessToken String? @map("access_token")${long}
208
+ refreshToken String? @map("refresh_token")${long}
209
+ idToken String? @map("id_token")${long}
210
+ accessTokenExpiresAt DateTime? @map("access_token_expires_at")
211
+ refreshTokenExpiresAt DateTime? @map("refresh_token_expires_at")
212
+ scope String?
213
+ password String?
214
+ createdAt DateTime @map("created_at")
215
+ updatedAt DateTime @map("updated_at")
216
+
217
+ @@map("account")
218
+ }
219
+
220
+ model Verification {
221
+ id String @id
222
+ identifier String
223
+ value String${long}
224
+ expiresAt DateTime @map("expires_at")
225
+ createdAt DateTime? @map("created_at")
226
+ updatedAt DateTime? @map("updated_at")
227
+
228
+ @@map("verification")
229
+ }
230
+
231
+ model Jwks {
232
+ id String @id
233
+ publicKey String${long} @map("public_key")
234
+ privateKey String${long} @map("private_key")
235
+ createdAt DateTime @map("created_at")
236
+ expiresAt DateTime? @map("expires_at")
237
+ alg String?
238
+ crv String?
239
+
240
+ @@map("jwks")
241
+ }
242
+ `
243
+ }
244
+
245
+ export const prismaAuthModels = (db) => authModels(db).replace(' todos Todo[]\n', '')
246
+
247
+ const prismaTodos = (auth) => {
248
+ const use = auth ? `\n auth: 'user',` : ''
249
+ const mine = auth ? `, userId: ctx.user.id` : ''
250
+ return `import { mutation, query } from '@kerf-js/start'
251
+ import { z } from 'zod'
252
+
253
+ const byId = z.object({ id: z.string() })
254
+
255
+ export const listTodos = query({
256
+ tags: ['todos'],${use}
257
+ run: ({ ctx }) => ctx.db.todo.findMany({ where: {${mine.slice(1)} }, orderBy: { createdAt: 'asc' }, select: { id: true, title: true, done: true } }),
258
+ })
259
+
260
+ export const addTodo = mutation({
261
+ input: z.object({ title: z.string().trim().min(1).max(200) }),${use}
262
+ invalidates: ['todos'],
263
+ optimistic: ({ input }, cache) =>
264
+ cache.update(listTodos, undefined, list => void list.push({ id: \`tmp:\${input.title}\`, title: input.title, done: false })),
265
+ run: async ({ input, ctx }) => {
266
+ await ctx.db.todo.create({ data: { id: crypto.randomUUID(), title: input.title${mine} } })
267
+ },
268
+ })
269
+
270
+ export const toggleTodo = mutation({
271
+ input: byId,${use}
272
+ invalidates: ['todos'],
273
+ optimistic: ({ input }, cache) =>
274
+ cache.update(listTodos, undefined, list => {
275
+ const t = list.find(x => x.id === input.id)
276
+ if (t) t.done = !t.done
277
+ }),
278
+ run: async ({ input, ctx }) => {
279
+ const todo = await ctx.db.todo.findFirst({ where: { id: input.id${mine} } })
280
+ if (todo) await ctx.db.todo.update({ where: { id: todo.id }, data: { done: !todo.done } })
281
+ },
282
+ })
283
+
284
+ export const deleteTodo = mutation({
285
+ input: byId,${use}
286
+ invalidates: ['todos'],
287
+ optimistic: ({ input }, cache) => cache.update(listTodos, undefined, list => list.filter(x => x.id !== input.id)),
288
+ run: async ({ input, ctx }) => {
289
+ await ctx.db.todo.deleteMany({ where: { id: input.id${mine} } })
290
+ },
291
+ })
292
+ `
293
+ }
294
+
295
+ export const prismaFiles = ({ db, auth }) => ({
296
+ 'prisma/schema.prisma': `generator client {
297
+ provider = "prisma-client"
298
+ output = "../src/generated/prisma"
299
+ }
300
+
301
+ datasource db {
302
+ provider = "${PROVIDER[db]}"
303
+ }
304
+ ${auth ? authModels(db) : ''}
305
+ model Todo {
306
+ id String @id
307
+ title String
308
+ done Boolean @default(false)
309
+ createdAt DateTime @default(now()) @map("created_at")${
310
+ auth
311
+ ? `
312
+ userId String @map("user_id")
313
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)`
314
+ : ''
315
+ }
316
+
317
+ @@map("todos")
318
+ }
319
+ `,
320
+ 'prisma.config.ts': `import { existsSync } from 'node:fs'
321
+ import { defineConfig } from 'prisma/config'
322
+
323
+ if (existsSync('.env')) process.loadEnvFile()
324
+
325
+ export default defineConfig({ schema: 'prisma/schema.prisma', datasource: { url: process.env.DATABASE_URL ?? '' } })
326
+ `,
327
+ 'src/db/index.server.ts': `${db === 'sqlite' ? "import { mkdirSync } from 'node:fs'\n" : ''}import { ${ADAPTER[db].name} } from '${ADAPTER[db].pkg}'
328
+ import { withKerf } from '@kerf-js/db/plugin-prisma'
329
+ import { PrismaClient } from '../generated/prisma/client'
330
+ import { env } from '../env.server'
331
+ ${db === 'sqlite' ? "\nmkdirSync('.data', { recursive: true })\n" : ''}
332
+ const adapter = new ${ADAPTER[db].name}(${ADAPTER[db].make})
333
+ export const db = withKerf(new PrismaClient({ adapter, log: [{ emit: 'event', level: 'query' }] }), '${PROVIDER[db]}')
334
+ `,
335
+ ...(auth && {
336
+ 'src/auth.server.ts': `import { createAuth } from '@kerf-js/start/auth/better-auth'
337
+ import { prismaAdapter } from 'better-auth/adapters/prisma'
338
+ import { db } from '#/db/index.server'
339
+ import { env } from './env.server'
340
+
341
+ export default createAuth({ db, secret: env.BETTER_AUTH_SECRET, options: { database: prismaAdapter(db, { provider: '${PROVIDER[db]}' }) } })
342
+ `,
343
+ }),
344
+ 'src/server/todos.ts': prismaTodos(auth),
345
+ })
346
+
347
+ /** `--auth-provider custom`: the seam, with nothing behind it yet. An app that compiles, with no one signed in. */
348
+ export const customAuth = `import { defineAuth } from '@kerf-js/start/auth'
349
+
350
+ // Your auth provider. kerf needs only these: \`handler\` serves everything under /api/auth, and \`session\` says who a
351
+ // request is, which is \`ctx.user\`. \`auth: 'user'\` on a query or mutation works with whatever you return here.
352
+ export default defineAuth<{ id: string }, { id: string }>({
353
+ async session(request) {
354
+ return { user: null, session: null }
355
+ },
356
+ async handler(request) {
357
+ return new Response('Not found', { status: 404 })
358
+ },
359
+ })
360
+ `