create-questpie 2.0.3 → 2.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 (153) hide show
  1. package/dist/index.mjs +544 -87
  2. package/package.json +2 -3
  3. package/templates/elysia/AGENTS.md +56 -0
  4. package/templates/elysia/CLAUDE.md +39 -0
  5. package/templates/elysia/Dockerfile +24 -0
  6. package/templates/elysia/README.md +148 -0
  7. package/templates/elysia/docker/init-extensions.sql +11 -0
  8. package/templates/elysia/docker-compose.yml +21 -0
  9. package/templates/elysia/env.example +16 -0
  10. package/templates/elysia/gitignore +6 -0
  11. package/templates/elysia/package.json +47 -0
  12. package/templates/elysia/questpie.config.ts +12 -0
  13. package/templates/elysia/src/index.ts +21 -0
  14. package/templates/elysia/src/lib/auth-client.ts +32 -0
  15. package/templates/elysia/src/lib/client.ts +13 -0
  16. package/templates/elysia/src/lib/env.ts +24 -0
  17. package/templates/elysia/src/lib/query-client.ts +18 -0
  18. package/templates/elysia/src/lib/query.ts +18 -0
  19. package/templates/elysia/src/questpie/server/.generated/context.gen.ts +200 -0
  20. package/templates/elysia/src/questpie/server/.generated/entities.gen.ts +84 -0
  21. package/templates/elysia/src/questpie/server/.generated/factories.ts +65 -0
  22. package/templates/elysia/src/questpie/server/.generated/index.ts +131 -0
  23. package/templates/elysia/src/questpie/server/.generated/names.gen.ts +25 -0
  24. package/templates/elysia/src/questpie/server/app.ts +10 -0
  25. package/templates/elysia/src/questpie/server/collections/index.ts +1 -0
  26. package/templates/elysia/src/questpie/server/collections/posts.collection.ts +10 -0
  27. package/templates/elysia/src/questpie/server/config/auth.ts +8 -0
  28. package/templates/elysia/src/questpie/server/config/openapi.ts +10 -0
  29. package/templates/elysia/src/questpie/server/globals/index.ts +1 -0
  30. package/templates/elysia/src/questpie/server/globals/site-settings.global.ts +10 -0
  31. package/templates/elysia/src/questpie/server/modules.ts +8 -0
  32. package/templates/elysia/src/questpie/server/questpie.config.ts +21 -0
  33. package/templates/elysia/tsconfig.json +28 -0
  34. package/templates/hono/AGENTS.md +56 -0
  35. package/templates/hono/CLAUDE.md +39 -0
  36. package/templates/hono/Dockerfile +24 -0
  37. package/templates/hono/README.md +148 -0
  38. package/templates/hono/docker/init-extensions.sql +11 -0
  39. package/templates/hono/docker-compose.yml +21 -0
  40. package/templates/hono/env.example +16 -0
  41. package/templates/hono/gitignore +6 -0
  42. package/templates/hono/package.json +47 -0
  43. package/templates/hono/questpie.config.ts +12 -0
  44. package/templates/hono/src/index.ts +30 -0
  45. package/templates/hono/src/lib/auth-client.ts +32 -0
  46. package/templates/hono/src/lib/client.ts +13 -0
  47. package/templates/hono/src/lib/env.ts +24 -0
  48. package/templates/hono/src/lib/query-client.ts +18 -0
  49. package/templates/hono/src/lib/query.ts +18 -0
  50. package/templates/hono/src/questpie/server/.generated/context.gen.ts +200 -0
  51. package/templates/hono/src/questpie/server/.generated/entities.gen.ts +84 -0
  52. package/templates/hono/src/questpie/server/.generated/factories.ts +65 -0
  53. package/templates/hono/src/questpie/server/.generated/index.ts +131 -0
  54. package/templates/hono/src/questpie/server/.generated/names.gen.ts +25 -0
  55. package/templates/hono/src/questpie/server/app.ts +10 -0
  56. package/templates/hono/src/questpie/server/collections/index.ts +1 -0
  57. package/templates/hono/src/questpie/server/collections/posts.collection.ts +10 -0
  58. package/templates/hono/src/questpie/server/config/auth.ts +8 -0
  59. package/templates/hono/src/questpie/server/config/openapi.ts +10 -0
  60. package/templates/hono/src/questpie/server/globals/index.ts +1 -0
  61. package/templates/hono/src/questpie/server/globals/site-settings.global.ts +10 -0
  62. package/templates/hono/src/questpie/server/modules.ts +8 -0
  63. package/templates/hono/src/questpie/server/questpie.config.ts +21 -0
  64. package/templates/hono/tsconfig.json +28 -0
  65. package/templates/next/AGENTS.md +55 -0
  66. package/templates/next/CLAUDE.md +39 -0
  67. package/templates/next/Dockerfile +25 -0
  68. package/templates/next/README.md +148 -0
  69. package/templates/next/components.json +22 -0
  70. package/templates/next/docker/init-extensions.sql +11 -0
  71. package/templates/next/docker-compose.yml +21 -0
  72. package/templates/next/env.example +16 -0
  73. package/templates/next/gitignore +10 -0
  74. package/templates/next/next-env.d.ts +5 -0
  75. package/templates/next/next.config.ts +20 -0
  76. package/templates/next/package.json +54 -0
  77. package/templates/next/postcss.config.mjs +8 -0
  78. package/templates/next/public/.gitkeep +0 -0
  79. package/templates/next/questpie.config.ts +12 -0
  80. package/templates/next/src/app/admin/[[...all]]/page.tsx +34 -0
  81. package/templates/next/src/app/admin/admin.css +4 -0
  82. package/templates/next/src/app/admin/layout.tsx +63 -0
  83. package/templates/next/src/app/api/[...all]/route.ts +24 -0
  84. package/templates/next/src/app/layout.tsx +24 -0
  85. package/templates/next/src/app/not-found.tsx +18 -0
  86. package/templates/next/src/app/page.tsx +74 -0
  87. package/templates/next/src/app/providers.tsx +11 -0
  88. package/templates/next/src/lib/auth-client.ts +12 -0
  89. package/templates/next/src/lib/client.ts +13 -0
  90. package/templates/next/src/lib/env.ts +24 -0
  91. package/templates/next/src/lib/query-client.ts +18 -0
  92. package/templates/next/src/lib/query.ts +18 -0
  93. package/templates/next/src/questpie/admin/.generated/client.ts +13 -0
  94. package/templates/next/src/questpie/admin/admin.ts +9 -0
  95. package/templates/next/src/questpie/admin/modules.ts +3 -0
  96. package/templates/next/src/questpie/server/.generated/context.gen.ts +204 -0
  97. package/templates/next/src/questpie/server/.generated/entities.gen.ts +100 -0
  98. package/templates/next/src/questpie/server/.generated/factories.ts +204 -0
  99. package/templates/next/src/questpie/server/.generated/index.ts +139 -0
  100. package/templates/next/src/questpie/server/.generated/names.gen.ts +31 -0
  101. package/templates/next/src/questpie/server/app.ts +10 -0
  102. package/templates/next/src/questpie/server/collections/index.ts +1 -0
  103. package/templates/next/src/questpie/server/collections/posts.collection.ts +58 -0
  104. package/templates/next/src/questpie/server/config/admin.ts +80 -0
  105. package/templates/next/src/questpie/server/config/auth.ts +8 -0
  106. package/templates/next/src/questpie/server/config/openapi.ts +10 -0
  107. package/templates/next/src/questpie/server/globals/index.ts +1 -0
  108. package/templates/next/src/questpie/server/globals/site-settings.global.ts +19 -0
  109. package/templates/next/src/questpie/server/modules.ts +9 -0
  110. package/templates/next/src/questpie/server/questpie.config.ts +21 -0
  111. package/templates/next/src/styles.css +125 -0
  112. package/templates/next/tsconfig.json +37 -0
  113. package/templates/tanstack-start/AGENTS.md +35 -600
  114. package/templates/tanstack-start/CLAUDE.md +26 -127
  115. package/templates/tanstack-start/README.md +20 -7
  116. package/templates/tanstack-start/docker/init-extensions.sql +11 -0
  117. package/templates/tanstack-start/docker-compose.yml +1 -0
  118. package/templates/tanstack-start/package.json +1 -0
  119. package/templates/tanstack-start/src/lib/auth-client.ts +1 -1
  120. package/templates/tanstack-start/src/lib/client.ts +1 -1
  121. package/templates/tanstack-start/src/lib/query.ts +18 -0
  122. package/templates/tanstack-start/src/questpie/admin/modules.ts +3 -1
  123. package/templates/tanstack-start/src/questpie/server/.generated/factories.ts +10 -9
  124. package/templates/tanstack-start/src/questpie/server/collections/index.ts +1 -1
  125. package/templates/tanstack-start/src/questpie/server/config/auth.ts +1 -1
  126. package/templates/tanstack-start/src/questpie/server/globals/index.ts +1 -1
  127. package/templates/tanstack-start/src/questpie/server/modules.ts +4 -5
  128. package/templates/tanstack-start/src/questpie/server/questpie.config.ts +3 -2
  129. package/templates/tanstack-start/src/routes/__root.tsx +31 -1
  130. package/templates/tanstack-start/src/routes/api/$.ts +2 -3
  131. package/templates/tanstack-start/src/routes/index.tsx +97 -0
  132. package/templates/tanstack-start/vite.config.ts +2 -2
  133. package/skills/questpie/AGENTS.md +0 -2670
  134. package/skills/questpie/SKILL.md +0 -260
  135. package/skills/questpie/references/auth.md +0 -121
  136. package/skills/questpie/references/business-logic.md +0 -550
  137. package/skills/questpie/references/codegen-plugin-api.md +0 -382
  138. package/skills/questpie/references/crud-api.md +0 -378
  139. package/skills/questpie/references/data-modeling.md +0 -493
  140. package/skills/questpie/references/extend.md +0 -557
  141. package/skills/questpie/references/field-types.md +0 -386
  142. package/skills/questpie/references/infrastructure-adapters.md +0 -545
  143. package/skills/questpie/references/multi-tenancy.md +0 -364
  144. package/skills/questpie/references/production.md +0 -475
  145. package/skills/questpie/references/query-operators.md +0 -125
  146. package/skills/questpie/references/quickstart.md +0 -564
  147. package/skills/questpie/references/rules.md +0 -389
  148. package/skills/questpie/references/tanstack-query.md +0 -520
  149. package/skills/questpie-admin/AGENTS.md +0 -1508
  150. package/skills/questpie-admin/SKILL.md +0 -436
  151. package/skills/questpie-admin/references/blocks.md +0 -331
  152. package/skills/questpie-admin/references/custom-ui.md +0 -305
  153. package/skills/questpie-admin/references/views.md +0 -449
@@ -1,260 +0,0 @@
1
- ---
2
- name: questpie
3
- description: QUESTPIE framework — server-first TypeScript CMS. File-convention codegen, collections, globals, routes, jobs, services, emails, blocks, typed client SDK, TanStack Query integration, adapters (queue, search, realtime, storage, email, KV). Use when building, reviewing, or refactoring any QUESTPIE project.
4
- license: MIT
5
- metadata:
6
- author: questpie
7
- version: "3.0.0"
8
- ---
9
-
10
- # QUESTPIE Framework
11
-
12
- Server-first TypeScript application framework. Define your data schema once using standalone factories, codegen generates the typed runtime, and any frontend consumes it through introspection.
13
-
14
- ## When to Apply
15
-
16
- Reference these guidelines when:
17
-
18
- - Creating or modifying collections, globals, routes, jobs, services, emails, blocks
19
- - Working with file conventions or codegen pipeline
20
- - Configuring adapters (queue, search, storage, realtime, email, KV)
21
- - Setting up access control, hooks, or validation
22
- - Building typed client SDK queries or TanStack Query integrations
23
- - Writing modules or plugins for QUESTPIE
24
- - Scaffolding a new project or onboarding
25
-
26
- ## Import Paths — Critical
27
-
28
- | Factory | Import From | Needs Codegen? |
29
- | ------------------------------ | ---------------------------- | -------------- |
30
- | `collection(name)` | `#questpie/factories` | Yes |
31
- | `global(name)` | `#questpie/factories` | Yes |
32
- | `block(name)` | `#questpie/factories` | Yes |
33
- | `adminConfig({...})` | `#questpie/factories` | Yes |
34
- | `route()` | `"questpie"` | No |
35
- | `job({...})` | `"questpie"` | No |
36
- | `service()` | `"questpie"` | No |
37
- | `email({...})` | `"questpie"` | No |
38
- | `migration({...})` | `"questpie"` | No |
39
- | `seed({...})` | `"questpie"` | No |
40
- | `runtimeConfig({...})` | `"questpie"` | No |
41
- | `appConfig({...})` | `"questpie"` | No |
42
- | `authConfig({...})` | `"questpie"` | No |
43
- | `createClient<AppConfig>()` | `"questpie/client"` | No |
44
- | `createQuestpieQueryOptions()` | `"@questpie/tanstack-query"` | No |
45
-
46
- ## Module And Plugin Configuration - Critical
47
-
48
- Codegen imports `modules.ts` before runtime app creation to extract module-contributed plugins. Any module that contributes a `plugin`, discover patterns, generated factories, categories, views, components, fields, or config factories must be statically discoverable from `modules.ts`.
49
-
50
- ### DO THIS
51
-
52
- Use a static module and a plugin-discovered config file for runtime options:
53
-
54
- ```ts title="modules.ts"
55
- import { observabilityModule } from "@questpie/observability/server";
56
-
57
- export default [observabilityModule] as const;
58
- ```
59
-
60
- ```ts title="config/observability.ts"
61
- import { observabilityConfig } from "@questpie/observability/server";
62
-
63
- export default observabilityConfig({
64
- serviceName: "barbershop",
65
- enabled: process.env.NODE_ENV === "production",
66
- });
67
- ```
68
-
69
- The module reads config at runtime from `app.state.config.observability`:
70
-
71
- ```ts
72
- export const observabilityModule = module({
73
- name: "questpie-observability",
74
- plugin: observabilityPlugin(),
75
- services: {
76
- observability: service({
77
- namespace: null,
78
- lifecycle: "singleton",
79
- create: ({ app, logger }) =>
80
- createObservabilityService(app.state.config?.observability, logger),
81
- }),
82
- },
83
- });
84
- ```
85
-
86
- ### DON'T DO THIS
87
-
88
- Do not make runtime options the primary API for codegen-aware modules:
89
-
90
- ```ts title="modules.ts"
91
- export default [
92
- observabilityModule({
93
- serviceName: "barbershop",
94
- }),
95
- ] as const;
96
- ```
97
-
98
- Do not conditionally hide codegen-aware modules or plugins behind env/runtime checks:
99
-
100
- ```ts title="modules.ts"
101
- export default [
102
- process.env.OTEL_ENABLED ? observabilityModule : undefined,
103
- ].filter(Boolean);
104
- ```
105
-
106
- Factory modules are acceptable only for simple runtime-only modules whose plugin identity and codegen contributions do not change. For reusable packages that ship a `CodegenPlugin`, prefer **static module + `config/*.ts` singleton factory**.
107
-
108
- ## Reference Topics
109
-
110
- ### Core
111
-
112
- | Topic | File | Covers |
113
- | --------------- | ------------------------------- | ------------------------------------------------------------------ |
114
- | Quickstart | `references/quickstart.md` | Scaffold, configure, codegen, migrate, serve — zero to running app |
115
- | Data Modeling | `references/data-modeling.md` | Collections, globals, fields, relations, options, localization |
116
- | Field Types | `references/field-types.md` | All built-in field types with options and operators |
117
- | Rules | `references/rules.md` | Access control (row/field level), hooks lifecycle, validation |
118
- | Business Logic | `references/business-logic.md` | Routes, jobs, services, email templates, context injection |
119
- | CRUD API | `references/crud-api.md` | Server-side `find`, `create`, `update`, `delete`, globals API |
120
- | Query Operators | `references/query-operators.md` | `where` clause operators by field type |
121
-
122
- ### Infrastructure
123
-
124
- | Topic | File | Covers |
125
- | ---------- | --------------------------------------- | ------------------------------------------------------------ |
126
- | Production | `references/production.md` | Queue, search, realtime, storage, email, KV adapter setup |
127
- | Auth | `references/auth.md` | Better Auth integration, session, providers, access patterns |
128
- | Adapters | `references/infrastructure-adapters.md` | All adapter configs: pg-boss, S3, SMTP, pgNotify, Redis |
129
-
130
- ### Extend
131
-
132
- | Topic | File | Covers |
133
- | ------------------ | ---------------------------------- | ------------------------------------------------------------ |
134
- | Extend | `references/extend.md` | Custom modules, fields, operators, adapters, codegen plugins |
135
- | Codegen Plugin API | `references/codegen-plugin-api.md` | Plugin architecture, category declarations, templates |
136
- | Multi-Tenancy | `references/multi-tenancy.md` | Scope isolation, workspace filtering, ScopeProvider |
137
-
138
- ### Client
139
-
140
- | Topic | File | Covers |
141
- | -------------- | ------------------------------ | ---------------------------------------------------------------- |
142
- | TanStack Query | `references/tanstack-query.md` | `q.collections.*`, `q.globals.*`, `q.routes.*`, realtime queries |
143
-
144
- ## Key Patterns — Quick Reference
145
-
146
- ### Collection
147
-
148
- ```ts
149
- import { collection } from "#questpie/factories";
150
-
151
- export default collection("posts")
152
- .fields(({ f }) => ({
153
- title: f.text().required(),
154
- status: f.select([{ value: "draft", label: "Draft" }]),
155
- author: f.relation("users").required(),
156
- }))
157
- .access({
158
- read: true,
159
- create: ({ session }) => !!session,
160
- update: ({ session, doc }) => doc.authorId === session?.user?.id,
161
- })
162
- .hooks({
163
- beforeChange: async ({ data, operation }) => {
164
- if (operation === "create") data.slug = slugify(data.title);
165
- return data;
166
- },
167
- })
168
- .options({ versioning: true, timestamps: true });
169
- ```
170
-
171
- ### Route
172
-
173
- ```ts
174
- import { route } from "questpie";
175
- import z from "zod";
176
-
177
- export default route()
178
- .post()
179
- .schema(z.object({ period: z.enum(["day", "week", "month"]) }))
180
- .handler(async ({ input, collections }) => {
181
- return collections.posts.find({ where: { status: "published" } });
182
- });
183
- ```
184
-
185
- ### Job
186
-
187
- ```ts
188
- import { job } from "questpie";
189
- import z from "zod";
190
-
191
- export default job({
192
- name: "sendReminder",
193
- schema: z.object({ userId: z.string() }),
194
- retryDelay: 5, // seconds (not ms!)
195
- handler: async ({ payload, email, collections }) => {
196
- const user = await collections.users.findOne({
197
- where: { id: payload.userId },
198
- });
199
- await email.send("reminder", { to: user.email, data: { name: user.name } });
200
- },
201
- });
202
- ```
203
-
204
- ### Client SDK
205
-
206
- ```ts
207
- import { createClient } from "questpie/client";
208
- import type { AppConfig } from "#questpie";
209
-
210
- const client = createClient<AppConfig>({
211
- baseURL:
212
- typeof window !== "undefined"
213
- ? window.location.origin
214
- : process.env.APP_URL,
215
- basePath: "/api",
216
- });
217
-
218
- const { docs } = await client.collections.posts.find({
219
- where: { status: "published" },
220
- orderBy: { createdAt: "desc" },
221
- with: { author: true },
222
- });
223
- ```
224
-
225
- ### Queue Dispatch
226
-
227
- ```ts
228
- // In any handler with AppContext:
229
- await queue.sendReminder.publish({ userId: "abc" });
230
- // NOT queue.send("sendReminder", payload)
231
- ```
232
-
233
- ## Common Mistakes
234
-
235
- | Severity | Mistake | Fix |
236
- | -------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------- |
237
- | CRITICAL | Files in wrong directory | Collections in `collections/`, routes in `routes/`, etc. |
238
- | CRITICAL | Missing `export default` on convention files | Codegen silently ignores files without default export |
239
- | CRITICAL | Importing route/job/service from `#questpie/factories` | Use `"questpie"` — only collection/global/block/adminConfig use `#questpie/factories` |
240
- | HIGH | Forgetting `questpie generate` after adding files | Re-run codegen on any file add/remove in convention dirs |
241
- | HIGH | Job handler uses `input` instead of `payload` | Jobs destructure `{ payload }`, routes destructure `{ input }` |
242
- | HIGH | `queue.send("name", data)` | Use `queue.jobName.publish(data)` |
243
- | HIGH | `beforeCreate` / `afterCreate` hook names | Use `beforeChange` / `afterChange` with `operation === "create"` guard |
244
- | HIGH | Runtime options in codegen-aware modules | Use static `module({...})` + plugin-discovered `config/*.ts` factory |
245
- | MEDIUM | Using npm/yarn instead of Bun | QUESTPIE requires Bun as package manager |
246
- | MEDIUM | Editing `.generated/` files | Never edit — re-run `questpie generate` |
247
-
248
- ## Preview And Workflow Rules
249
-
250
- - Live Preview uses the existing admin `FormView`, Preview button, `LivePreviewMode`, and iframe. Do not introduce a separate visual-edit form API, a second default form view, or parallel preview API names.
251
- - Preserve save, autosave, Cmd+S, history, workflow transitions, locks, and actions in the normal form lifecycle.
252
- - Frontend visual editing needs `useCollectionPreview`, `PreviewProvider`, `PreviewField`, and usually `BlockRenderer`; load the `questpie-admin` skill for the full frontend preparation checklist.
253
- - For publishable pages with workflow enabled, workflow stage is the publication source. Public frontend reads use `stage: "published"`.
254
- - If public client/HTTP access is enabled, anonymous read access should require `input?.stage === "published"`; editor/preview reads can omit `stage` only when a session is present.
255
- - Preview/draft-mode reads may load the working stage for authorized editors.
256
- - Do not add duplicate `isPublished` guidance when workflow already controls publishing.
257
-
258
- ## Full Compiled Document
259
-
260
- For the complete framework reference with all topics expanded: `AGENTS.md`
@@ -1,121 +0,0 @@
1
- # Authentication Reference
2
-
3
- Detailed authentication configuration for QUESTPIE using Better Auth.
4
-
5
- ## File Convention
6
-
7
- Auth is configured via `config/auth.ts` using the `authConfig()` factory:
8
-
9
- ```ts
10
- // src/questpie/server/config/auth.ts
11
- import { authConfig } from "questpie";
12
-
13
- export default authConfig({
14
- emailAndPassword: {
15
- enabled: true,
16
- requireEmailVerification: false,
17
- },
18
- baseURL: process.env.APP_URL || "http://localhost:3000",
19
- basePath: "/api/auth",
20
- secret: process.env.BETTER_AUTH_SECRET || "change-me",
21
- });
22
- ```
23
-
24
- Codegen discovers this file automatically. No manual registration needed.
25
-
26
- ## Configuration Options
27
-
28
- | Option | Type | Default | Description |
29
- | ------------------------------------------- | --------- | ------------- | ----------------------------------------------------------- |
30
- | `emailAndPassword.enabled` | `boolean` | `false` | Enable email/password authentication |
31
- | `emailAndPassword.requireEmailVerification` | `boolean` | `false` | Require email verification before login |
32
- | `baseURL` | `string` | — | Application public URL (used for OAuth callbacks) |
33
- | `basePath` | `string` | `"/api/auth"` | Auth API route prefix |
34
- | `secret` | `string` | — | Session signing secret. **Must be 32+ chars in production** |
35
-
36
- ## Session Access
37
-
38
- ### In Routes
39
-
40
- ```ts
41
- import { route } from "questpie";
42
- import z from "zod";
43
-
44
- export default route()
45
- .post()
46
- .schema(z.object({ postId: z.string() }))
47
- .handler(async ({ input, session, collections }) => {
48
- if (!session) {
49
- throw new Error("Not authenticated");
50
- }
51
-
52
- const user = session.user;
53
- // user.id - unique user ID
54
- // user.email - user email address
55
- // user.name - user display name
56
-
57
- const post = await collections.posts.create({
58
- title: "My Post",
59
- author: user.id,
60
- });
61
-
62
- return post;
63
- });
64
- ```
65
-
66
- ### In Hooks
67
-
68
- ```ts
69
- .hooks({
70
- beforeChange: async ({ data, operation, session }) => {
71
- if (operation === "create") {
72
- if (!session) throw new Error("Must be logged in");
73
- data.createdBy = session.user.id;
74
- }
75
- return data;
76
- },
77
- })
78
- ```
79
-
80
- ### In Access Rules
81
-
82
- ```ts
83
- .access({
84
- // Public read
85
- read: true,
86
-
87
- // Authenticated users can create
88
- create: ({ session }) => !!session,
89
-
90
- // Only admins can update/delete
91
- update: ({ session }) => (session?.user as any)?.role === "admin",
92
- delete: ({ session }) => (session?.user as any)?.role === "admin",
93
- })
94
- ```
95
-
96
- ## User Collection
97
-
98
- The `adminModule` provides a built-in `user` collection. It stores:
99
-
100
- - `id` -- unique identifier
101
- - `email` -- email address
102
- - `name` -- display name
103
- - `image` -- avatar URL
104
- - `emailVerified` -- verification status
105
-
106
- This collection is automatically created when you add the admin module to your config.
107
-
108
- ## Environment Variables
109
-
110
- | Variable | Required | Description |
111
- | -------------------- | ---------- | --------------------------------------------------------- |
112
- | `APP_URL` | Yes | Public URL -- used for OAuth callback URLs |
113
- | `BETTER_AUTH_SECRET` | Yes (prod) | Session signing secret. Use a random 32+ character string |
114
-
115
- ## Production Security Checklist
116
-
117
- 1. Set `BETTER_AUTH_SECRET` to a strong random value (32+ chars)
118
- 2. Set `APP_URL` to your production domain (HTTPS)
119
- 3. Enable `requireEmailVerification` if using email/password
120
- 4. Use HTTPS for all auth endpoints
121
- 5. Configure proper CORS if API and frontend are on different domains