void 0.22.0 → 0.23.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.
- package/README.md +5 -1
- package/dist/{account-cmd-CjyxcGkM.mjs → account-cmd-C84Ee8cO.mjs} +4 -4
- package/dist/{scan-ClYmX3sa.mjs → application-analysis-BVsVqc11.mjs} +135 -18
- package/dist/application-routing-B7QEjqSR.mjs +27 -0
- package/dist/{auth-CZuiVsFh.mjs → auth-CCjt0hcq.mjs} +1 -1
- package/dist/{auth-DLNN0D3Z.mjs → auth-CSkdO2Bb.mjs} +4 -47
- package/dist/{auth-link-BLO4ptzo.mjs → auth-link-CioEg6uY.mjs} +4 -4
- package/dist/{auth-router-ZUg9MF_U.mjs → auth-router-BsR981d4.mjs} +4 -4
- package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
- package/dist/{build-cmd-BxR5FROK.mjs → build-cmd-LzvNJORH.mjs} +17 -5
- package/dist/{cache-D0sWhgKI.mjs → cache-C4MvnrMH.mjs} +2 -2
- package/dist/{cancel-deploy-D4NUqFbi.mjs → cancel-deploy-abUxpP2n.mjs} +2 -2
- package/dist/{cf-build-output-BJ6yGEIS.mjs → cf-build-output-BPqOT964.mjs} +2 -1
- package/dist/cf-build-output-_0HNWysu.mjs +2 -0
- package/dist/cli/cli.mjs +80 -455
- package/dist/cli/{cf-compat.mjs → cloudflare-operation-process.mjs} +442 -421
- package/dist/cli/env-schema-probe.d.mts +2 -1
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-Cu7jWiF1.mjs +2 -0
- package/dist/{client-BTZ3XkrB.mjs → client-RV8NVeB8.mjs} +140 -21
- package/dist/{cloudflare-auth-DQkqoMYa.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -38
- package/dist/{cloudflare-cmd-BKlfGHAy.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +5 -5
- package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
- package/dist/{cloudflare-connect-Ctmrw579.mjs → cloudflare-connect-B8uPZ4nx.mjs} +3 -3
- package/dist/{cloudflare-operations-BT6OWFBk.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
- package/dist/{cloudflare-operations-B9tzgjmf.mjs → cloudflare-operations-fxHb-byx.mjs} +116 -172
- package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
- package/dist/{config-VavjpDnp.d.mts → config-BMHb8RCj.d.mts} +1 -0
- package/dist/config-C_XRIPx2.mjs +89 -0
- package/dist/config-entry.d.mts +1 -1
- package/dist/{connect-Dg-WkW-C.mjs → connect-Bd4kJd9U.mjs} +5 -5
- package/dist/{create-project-DdoqwFLF.mjs → create-project-Boczwj5r.mjs} +1 -1
- package/dist/{create-project-l9J7pbtm.mjs → create-project-bMf6ffLZ.mjs} +2 -2
- package/dist/{db-gp2sCXyN.mjs → db-8uG64XLl.mjs} +21 -21
- package/dist/{delete-TTedbH6B.mjs → delete-NvbiyeJf.mjs} +2 -2
- package/dist/{deploy-CH-o2CaZ.mjs → deploy-DzAIwqNU.mjs} +908 -582
- package/dist/{deploy-B19L2Bra.mjs → deploy-bjXdFCtn.mjs} +1 -1
- package/dist/{domain-JRF59P_r.mjs → domain-y5Tvydvo.mjs} +3 -3
- package/dist/{email-Bo6G9LOZ.mjs → email-B3umsW75.mjs} +13 -28
- package/dist/{env-BYOrWQnv.mjs → env-BS6qYHDb.mjs} +4 -4
- package/dist/{env-public-BxU_0yTL.d.mts → env-public-BX_r8HR6.d.mts} +1 -1
- package/dist/{env-validation-BB4GkLxn.mjs → env-validation-BPn7vk-V.mjs} +18 -71
- package/dist/{env-validation-BXge7uyK.mjs → env-validation-DbTg7-ar.mjs} +1 -1
- package/dist/{fetch-CXDChK7B.mjs → fetch-BIZJh7vR.mjs} +2 -2
- package/dist/{fetch-stream-AOByI7Ki.mjs → fetch-stream-IvCYKyQL.mjs} +24 -4
- package/dist/{gen-sCtlCOdA.mjs → gen-B580--vC.mjs} +2 -2
- package/dist/gen-BVaUUumi.mjs +2 -0
- package/dist/{github-cmd-0-7PexDq.mjs → github-cmd-v45BdfKX.mjs} +2 -2
- package/dist/{handler-HEcZsaij.d.mts → handler-CZ4nAylQ.d.mts} +1 -1
- package/dist/help-DofyZuY7.mjs +2 -0
- package/dist/{help-GKtwl07I.mjs → help-daGKjXGk.mjs} +229 -747
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +288 -1502
- package/dist/info-B97bTX9N.mjs +113 -0
- package/dist/{init-FZx3Elvz.mjs → init-Bvy7zrBo.mjs} +46 -15
- package/dist/limits-Bq5LG8Id.d.mts +27 -0
- package/dist/limits-Cjuk2VPm.mjs +68 -0
- package/dist/{link-BrQfb_CU.mjs → link-CDqqCjFl.mjs} +3 -3
- package/dist/{list-D44jmIAM.mjs → list-CZj0dzKY.mjs} +3 -3
- package/dist/{live-CKJlvlNp.d.mts → live-Chw1eIMv.d.mts} +1 -1
- package/dist/{local-d1-Bg9OzEEO.mjs → local-d1-2CMnpuW_.mjs} +2 -2
- package/dist/login-DYt_An22.mjs +2 -0
- package/dist/{login-CAsAsQ-_.mjs → login-UZKFM_u7.mjs} +3 -3
- package/dist/{logs-BjKvFnVM.mjs → logs-CUZ6t9t3.mjs} +3 -3
- package/dist/migrate-8_2u55MD.mjs +2 -0
- package/dist/{migrate-BPITvDJN.mjs → migrate-DHul7PRV.mjs} +2 -1
- package/dist/{node-Dt7z256D.mjs → node-BkyRWRx8.mjs} +1 -1
- package/dist/operator-args-CLgKGlwU.mjs +690 -0
- package/dist/{operator-cmd-BK5CCiT9.mjs → operator-cmd-DBA6dl0m.mjs} +68 -22
- package/dist/pages/client.d.mts +34 -2
- package/dist/pages/client.mjs +59 -3
- package/dist/pages/index.d.mts +1 -1
- package/dist/pages/index.mjs +1 -1
- package/dist/pages/islands-plugin.mjs +1 -1
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +2 -308
- package/dist/{parse-filename-DioPHiR9.mjs → parse-filename-CUbj-1MP.mjs} +35 -1
- package/dist/plan-D1Q5rf-r.mjs +2 -0
- package/dist/plan-NPpwZ_kc.mjs +58 -0
- package/dist/platform-args-BJdRtlLq.mjs +506 -0
- package/dist/platform-args-D3RXyR6h.mjs +2 -0
- package/dist/{platform-auth-config-BlN8xTdD.mjs → platform-auth-config-B56E9YP1.mjs} +3 -3
- package/dist/{platform-auth-protection-7d5aV2Jg.mjs → platform-auth-protection-BDWO_aER.mjs} +2 -2
- package/dist/{platform-auth-recovery-Dxij8ZbR.mjs → platform-auth-recovery-1gg4CSRe.mjs} +3 -3
- package/dist/{platform-cmd-E0FuL212.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
- package/dist/{platform-cmd-B3hwKrFK.mjs → platform-cmd-DMcQStSc.mjs} +24 -3
- package/dist/{platform-domain-D6Xcy9ZX.mjs → platform-domain-BNkcz0OB.mjs} +2 -2
- package/dist/{platform-lifecycle-k0E0xoxx.mjs → platform-lifecycle-9OyBALhH.mjs} +327 -215
- package/dist/{platform-lifecycle-DMh_qrry.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
- package/dist/{platform-management-Brz_BDiT.mjs → platform-management-CjwLVQwN.mjs} +6 -3
- package/dist/{platform-management-DOtss0BN.mjs → platform-management-CnyTdcWX.mjs} +1 -1
- package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
- package/dist/{platform-recovery-BvtcXON5.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
- package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
- package/dist/{prepare-C-6YZyyg.mjs → prepare-B5Mkic5u.mjs} +1 -1
- package/dist/{prepare-CRhJbVrG.mjs → prepare-DOsL0CC9.mjs} +4 -20
- package/dist/prepare-cgvDMtSb.mjs +2 -0
- package/dist/{project-cmd-BZLCqOqw.mjs → project-cmd-CNzrqvBv.mjs} +16 -16
- package/dist/{project-team-BvgM0WoX.mjs → project-team-DQOWPfQT.mjs} +2 -2
- package/dist/{project-token-l5DqK6Az.mjs → project-token-CTDYU0Cc.mjs} +2 -2
- package/dist/{project-zero-trust-v6Mvpp8y.mjs → project-zero-trust-BNAkW-_0.mjs} +2 -2
- package/dist/{protocol-BBa6cstI.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
- package/dist/protocol-U7bfjHmA.mjs +331 -0
- package/dist/{provision-Fr9pRqce.mjs → provision-C4ORE7G7.mjs} +1 -1
- package/dist/{provision-C4IGqkBf.mjs → provision-CJFgTZY8.mjs} +89 -198
- package/dist/{requests-DN-BbNiM.mjs → requests-MhxYnau8.mjs} +2 -2
- package/dist/resource-name-C7LVpcRm.mjs +11 -0
- package/dist/{rollback-D7rzSaZM.mjs → rollback-CJ6iSDoU.mjs} +3 -3
- package/dist/route-url-CG7U-cRN.mjs +15 -0
- package/dist/{runner-B8wXwWlo.mjs → runner-CXA9Fh8h.mjs} +1 -1
- package/dist/{runner-p-dMs2UN.mjs → runner-Ol0TNjk6.mjs} +2 -2
- package/dist/runtime/ai.d.mts +12 -8
- package/dist/runtime/ai.mjs +84 -17
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.mjs +2 -2
- package/dist/runtime/client-solid.mjs +2 -2
- package/dist/runtime/client-svelte.mjs +2 -2
- package/dist/runtime/client-vue.mjs +2 -2
- package/dist/runtime/client.mjs +2 -2
- package/dist/runtime/durable.d.mts +3 -1
- package/dist/runtime/durable.mjs +4 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-public.d.mts +1 -1
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/kv.mjs +0 -1
- package/dist/runtime/limits.d.mts +2 -0
- package/dist/runtime/limits.mjs +2 -0
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +25 -16
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/migration-handler.mjs +62 -42
- package/dist/runtime/route-url.d.mts +4 -0
- package/dist/runtime/route-url.mjs +2 -0
- package/dist/runtime/routing.d.mts +180 -0
- package/dist/runtime/routing.mjs +1082 -0
- package/dist/runtime/sandbox-container.d.mts +1 -1
- package/dist/runtime/sandbox-container.mjs +1 -1
- package/dist/runtime/sandbox.d.mts +3 -3
- package/dist/runtime/sandbox.mjs +75 -45
- package/dist/runtime/sse.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +4 -2
- package/dist/runtime/ws-server.mjs +27 -2
- package/dist/runtime/ws.d.mts +2 -2
- package/dist/runtime/ws.mjs +8 -6
- package/dist/{sandbox-qpNBT8a3.d.mts → sandbox-XZAqzFlG.d.mts} +11 -8
- package/dist/{sandbox-container-DdNEBfCc.d.mts → sandbox-container-Bo0eiFKz.d.mts} +2 -1
- package/dist/{sandbox-container-4fdqLnyb.mjs → sandbox-container-C6ItmVuN.mjs} +4 -2
- package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
- package/dist/{secret-BOtOl_cb.mjs → secret-Dli5fP0B.mjs} +4 -4
- package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
- package/dist/validate-Dq_L3s0S.mjs +2 -0
- package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
- package/dist/{wrangler-DQF1vKyf.mjs → wrangler-7K-bW_DL.mjs} +8 -239
- package/dist/{ws-BoY7vQML.d.mts → ws-CL1w7GXU.d.mts} +13 -2
- package/package.json +15 -8
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
- package/skills/void/SKILL.md +50 -135
- package/skills/void/docs/guide/ai.md +94 -84
- package/skills/void/docs/guide/app-types.md +3 -32
- package/skills/void/docs/guide/auth.md +12 -116
- package/skills/void/docs/guide/database/d1.md +9 -54
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +5 -26
- package/skills/void/docs/guide/database.md +23 -75
- package/skills/void/docs/guide/deployment.md +27 -113
- package/skills/void/docs/guide/durable-state.md +43 -18
- package/skills/void/docs/guide/edge/headers.md +3 -47
- package/skills/void/docs/guide/edge/prerendering.md +5 -20
- package/skills/void/docs/guide/edge/redirects.md +11 -64
- package/skills/void/docs/guide/edge/revalidation.md +5 -18
- package/skills/void/docs/guide/edge/rewrites.md +56 -284
- package/skills/void/docs/guide/edge/static-assets.md +22 -72
- package/skills/void/docs/guide/email/domains.md +112 -0
- package/skills/void/docs/guide/email/receiving.md +139 -0
- package/skills/void/docs/guide/email/sending.md +231 -0
- package/skills/void/docs/guide/email.md +13 -619
- package/skills/void/docs/guide/env-migration.md +11 -11
- package/skills/void/docs/guide/env-vars.md +9 -29
- package/skills/void/docs/guide/index.md +0 -15
- package/skills/void/docs/guide/jobs.md +3 -18
- package/skills/void/docs/guide/kv.md +5 -11
- package/skills/void/docs/guide/live.md +5 -56
- package/skills/void/docs/guide/pages-routing/actions-and-forms.md +78 -125
- package/skills/void/docs/guide/pages-routing/head.md +10 -10
- package/skills/void/docs/guide/pages-routing/islands.md +6 -36
- package/skills/void/docs/guide/pages-routing/layouts.md +6 -128
- package/skills/void/docs/guide/pages-routing/loaders.md +3 -19
- package/skills/void/docs/guide/pages-routing/markdown.md +13 -171
- package/skills/void/docs/guide/pages-routing/overview.md +7 -17
- package/skills/void/docs/guide/pages-routing/view-transitions.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +1 -4
- package/skills/void/docs/guide/platform/administration/email.md +35 -8
- package/skills/void/docs/guide/platform/administration/operations.md +26 -4
- package/skills/void/docs/guide/platform/administration/plans.md +126 -0
- package/skills/void/docs/guide/platform/administration/projects.md +5 -2
- package/skills/void/docs/guide/platform/administration/zero-trust.md +23 -152
- package/skills/void/docs/guide/platform/development/runtime.md +3 -13
- package/skills/void/docs/guide/platform/development/schema-ci.md +0 -58
- package/skills/void/docs/guide/platform/installation/credentials.md +6 -4
- package/skills/void/docs/guide/platform/installation/domains.md +30 -2
- package/skills/void/docs/guide/platform/installation/first-deployment.md +2 -0
- package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
- package/skills/void/docs/guide/platform/installation/prerequisites.md +20 -15
- package/skills/void/docs/guide/platform/installation/setup.md +9 -5
- package/skills/void/docs/guide/platform-administration.md +1 -0
- package/skills/void/docs/guide/queues.md +7 -9
- package/skills/void/docs/guide/quickstart.md +38 -37
- package/skills/void/docs/guide/remote-dev.md +4 -9
- package/skills/void/docs/guide/sandboxes.md +29 -21
- package/skills/void/docs/guide/server-routing.md +9 -72
- package/skills/void/docs/guide/sse.md +4 -18
- package/skills/void/docs/guide/ssg.md +3 -15
- package/skills/void/docs/guide/ssr.md +14 -62
- package/skills/void/docs/guide/storage.md +9 -4
- package/skills/void/docs/guide/type-safety.md +3 -14
- package/skills/void/docs/guide/typed-fetch.md +3 -7
- package/skills/void/docs/guide/websockets.md +68 -40
- package/skills/void/docs/integrations/agents.md +3 -3
- package/skills/void/docs/integrations/cloudflare.md +85 -316
- package/skills/void/docs/integrations/frameworks/analog.md +5 -64
- package/skills/void/docs/integrations/frameworks/astro.md +4 -73
- package/skills/void/docs/integrations/frameworks/nuxt.md +5 -62
- package/skills/void/docs/integrations/frameworks/overview.md +11 -54
- package/skills/void/docs/integrations/frameworks/react-router.md +5 -60
- package/skills/void/docs/integrations/frameworks/sveltekit.md +6 -65
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +4 -62
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -69
- package/skills/void/docs/reference/api/auth.md +156 -0
- package/skills/void/docs/reference/api/client.md +87 -0
- package/skills/void/docs/reference/api/database.md +95 -0
- package/skills/void/docs/reference/api/durable.md +46 -0
- package/skills/void/docs/reference/api/env.md +50 -0
- package/skills/void/docs/reference/api/handlers.md +254 -0
- package/skills/void/docs/reference/api/pages.md +241 -0
- package/skills/void/docs/reference/api/plugin.md +39 -0
- package/skills/void/docs/reference/api/resources.md +109 -0
- package/skills/void/docs/reference/api/rewrites.md +76 -0
- package/skills/void/docs/reference/api/types.md +92 -0
- package/skills/void/docs/reference/api.md +56 -1218
- package/skills/void/docs/reference/cli/auth.md +88 -0
- package/skills/void/docs/reference/cli/database.md +128 -0
- package/skills/void/docs/reference/cli/deploy.md +85 -0
- package/skills/void/docs/reference/cli/domains.md +41 -0
- package/skills/void/docs/reference/cli/email.md +129 -0
- package/skills/void/docs/reference/cli/generate.md +116 -0
- package/skills/void/docs/reference/cli/github.md +189 -0
- package/skills/void/docs/reference/cli/platform-config.md +92 -0
- package/skills/void/docs/reference/cli/platform-email.md +81 -0
- package/skills/void/docs/reference/cli/platform-installation.md +127 -0
- package/skills/void/docs/reference/cli/platform-operations.md +90 -0
- package/skills/void/docs/reference/cli/platform-users.md +89 -0
- package/skills/void/docs/reference/cli/platform-zero-trust.md +45 -0
- package/skills/void/docs/reference/cli/platform.md +70 -0
- package/skills/void/docs/reference/cli/project.md +214 -0
- package/skills/void/docs/reference/cli/secrets.md +76 -0
- package/skills/void/docs/reference/cli/setup.md +70 -0
- package/skills/void/docs/reference/cli.md +32 -1682
- package/skills/void/docs/reference/config.md +12 -18
- package/skills/void/docs/reference/resource-inference.md +3 -58
- package/skills/void/docs/reference/structure.md +14 -41
- package/dist/canonical-json-DuDiiUsQ.mjs +0 -13
- package/dist/client-Czz8o5jP.mjs +0 -2
- package/dist/gen-CNJ62MM7.mjs +0 -2
- package/dist/help-CmZzxUba.mjs +0 -2
- package/dist/login-CGcRKEoi.mjs +0 -2
- package/dist/migrate-CYfbKkXh.mjs +0 -2
- package/dist/plan-BEZ8VJW0.mjs +0 -256
- package/dist/plan-DpuOr14e.mjs +0 -2
- package/dist/prepare-Bm3iq-u4.mjs +0 -2
- package/dist/validate-EKmJWxmy.mjs +0 -2
- /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
|
@@ -5,7 +5,7 @@ outline: deep
|
|
|
5
5
|
# Authentication
|
|
6
6
|
|
|
7
7
|
::: warning ⚠️ Void Apps Only
|
|
8
|
-
Void-managed auth
|
|
8
|
+
Void-managed auth requires a native Void app on Cloudflare. For meta-frameworks or Node.js, Bun, and Deno, use Better Auth directly.
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
Void configures [Better Auth](https://www.better-auth.com/) for your app, including its database connection, API routes, and client. Start with email and password, or add a social login provider.
|
|
@@ -14,17 +14,7 @@ Void configures [Better Auth](https://www.better-auth.com/) for your app, includ
|
|
|
14
14
|
|
|
15
15
|
### 1. Enable auth
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```json
|
|
20
|
-
{
|
|
21
|
-
"auth": {
|
|
22
|
-
"providers": ["email"]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
You can also skip this step entirely. Auth activates automatically when you import from `void/auth` or `void/client`.
|
|
17
|
+
Import `auth` from `void/client` to enable email/password auth automatically. Use [configuration](#config) to add social providers.
|
|
28
18
|
|
|
29
19
|
### 2. Sign up and sign in
|
|
30
20
|
|
|
@@ -36,14 +26,14 @@ import { auth } from 'void/client';
|
|
|
36
26
|
// sign up
|
|
37
27
|
await auth.signUp.email({
|
|
38
28
|
email: 'alice@example.com',
|
|
39
|
-
password: '
|
|
29
|
+
password: 'example-password-123',
|
|
40
30
|
name: 'Alice',
|
|
41
31
|
});
|
|
42
32
|
|
|
43
33
|
// sign in
|
|
44
34
|
await auth.signIn.email({
|
|
45
35
|
email: 'alice@example.com',
|
|
46
|
-
password: '
|
|
36
|
+
password: 'example-password-123',
|
|
47
37
|
});
|
|
48
38
|
```
|
|
49
39
|
|
|
@@ -83,8 +73,6 @@ export const loader = defineHandler(() => {
|
|
|
83
73
|
await auth.signOut();
|
|
84
74
|
```
|
|
85
75
|
|
|
86
|
-
The rest of this page covers configuration, server helpers, and advanced customization in detail.
|
|
87
|
-
|
|
88
76
|
## Config
|
|
89
77
|
|
|
90
78
|
Auth turns on automatically when you:
|
|
@@ -94,9 +82,7 @@ Auth turns on automatically when you:
|
|
|
94
82
|
- add `auth` to `void.config.ts`
|
|
95
83
|
- add a root-level `auth.ts` file
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Example:
|
|
85
|
+
Email/password is enabled by default. To add social providers:
|
|
100
86
|
|
|
101
87
|
```json
|
|
102
88
|
{
|
|
@@ -117,38 +103,9 @@ For example, `github` uses:
|
|
|
117
103
|
|
|
118
104
|
## Client Usage
|
|
119
105
|
|
|
120
|
-
`
|
|
121
|
-
|
|
122
|
-
```ts
|
|
123
|
-
import { auth } from 'void/client';
|
|
124
|
-
|
|
125
|
-
await auth.signUp.email({
|
|
126
|
-
email: 'alice@example.com',
|
|
127
|
-
password: 's3cret',
|
|
128
|
-
name: 'Alice',
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await auth.signIn.email({
|
|
132
|
-
email: 'alice@example.com',
|
|
133
|
-
password: 's3cret',
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
await auth.signOut();
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
The client uses Better Auth's API, configured at `/api/auth`.
|
|
140
|
-
|
|
141
|
-
See the official [Better Auth client docs](https://www.better-auth.com/docs/concepts/client) for the full client API.
|
|
142
|
-
|
|
143
|
-
Framework-specific clients are selected automatically:
|
|
144
|
-
|
|
145
|
-
- React pages apps use `better-auth/react`
|
|
146
|
-
- Vue pages apps use `better-auth/vue`
|
|
147
|
-
- Svelte pages apps use `better-auth/svelte`
|
|
148
|
-
- Solid pages apps use `better-auth/solid`
|
|
149
|
-
- other Void apps use `better-auth/client`
|
|
106
|
+
The `auth` client uses [Better Auth's client API](https://www.better-auth.com/docs/concepts/client) at `/api/auth`. Void selects the client for your framework automatically.
|
|
150
107
|
|
|
151
|
-
For
|
|
108
|
+
For a custom client, import `createAuthClient` from `void/client`.
|
|
152
109
|
|
|
153
110
|
## Server Usage
|
|
154
111
|
|
|
@@ -162,67 +119,13 @@ import { getSession, getUser, requireAuth } from 'void/auth';
|
|
|
162
119
|
- `getSession()` returns `{ user, session } | null`
|
|
163
120
|
- `requireAuth(c)` returns the authenticated user or throws `401`
|
|
164
121
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```ts
|
|
168
|
-
import { defineHandler } from 'void';
|
|
169
|
-
import { requireAuth } from 'void/auth';
|
|
170
|
-
|
|
171
|
-
export const GET = defineHandler((c) => {
|
|
172
|
-
const user = requireAuth(c);
|
|
173
|
-
return { email: user.email };
|
|
174
|
-
});
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### `AuthUser`
|
|
178
|
-
|
|
179
|
-
`AuthUser` maps to Better Auth's core user type:
|
|
180
|
-
|
|
181
|
-
```ts
|
|
182
|
-
interface AuthUser {
|
|
183
|
-
id: string;
|
|
184
|
-
email: string;
|
|
185
|
-
emailVerified: boolean;
|
|
186
|
-
name: string;
|
|
187
|
-
image?: string | null;
|
|
188
|
-
createdAt: Date;
|
|
189
|
-
updatedAt: Date;
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### `AuthSession`
|
|
194
|
-
|
|
195
|
-
`AuthSession` maps to Better Auth's core session type:
|
|
196
|
-
|
|
197
|
-
```ts
|
|
198
|
-
interface AuthSession {
|
|
199
|
-
id: string;
|
|
200
|
-
token: string;
|
|
201
|
-
userId: string;
|
|
202
|
-
expiresAt: Date;
|
|
203
|
-
createdAt: Date;
|
|
204
|
-
updatedAt: Date;
|
|
205
|
-
ipAddress?: string | null;
|
|
206
|
-
userAgent?: string | null;
|
|
207
|
-
}
|
|
208
|
-
```
|
|
122
|
+
Import `AuthUser` and `AuthSession` from `void/auth` for type annotations. See their fields in the [API reference](../reference/api/auth.md#authuser).
|
|
209
123
|
|
|
210
124
|
## Behavior
|
|
211
125
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
- mount path: `/api/auth/*`
|
|
215
|
-
- email/password enabled by default unless `auth.providers` is set without `"email"`
|
|
216
|
-
- `auth.providers` can enable any built-in Better Auth social provider
|
|
217
|
-
- deployed apps need an auth secret via `BETTER_AUTH_SECRET`
|
|
218
|
-
- D1/SQLite uses the app `DB` binding
|
|
219
|
-
- PostgreSQL apps (`"database": "pg"`) use the app `HYPERDRIVE` binding
|
|
220
|
-
|
|
221
|
-
Auth sessions live in the same database system as the rest of the app.
|
|
222
|
-
|
|
223
|
-
On both deployment targets, Void keeps an existing `BETTER_AUTH_SECRET` or generates one when it's missing. The value is stored as an encrypted Worker secret and reused by later versions.
|
|
126
|
+
Auth sessions use the same database as your app. Void creates `BETTER_AUTH_SECRET` on deploy if it is missing and reuses it on later deploys.
|
|
224
127
|
|
|
225
|
-
|
|
128
|
+
Local development needs no secret setup. To preview a production build locally, provide `BETTER_AUTH_SECRET`.
|
|
226
129
|
|
|
227
130
|
## Customization
|
|
228
131
|
|
|
@@ -245,19 +148,12 @@ For the full set of available options, see the official [Better Auth options ref
|
|
|
245
148
|
|
|
246
149
|
Auth tables live alongside your app's tables. During local development, Void creates them automatically.
|
|
247
150
|
|
|
248
|
-
|
|
151
|
+
Void platforms create auth tables automatically. For a direct Cloudflare deploy, include them in your checked-in migrations:
|
|
249
152
|
|
|
250
153
|
```sh
|
|
251
154
|
void db generate
|
|
252
155
|
```
|
|
253
156
|
|
|
254
|
-
|
|
157
|
+
Review and commit the SQL before deploying. Void includes your auth configuration and plugin tables; you don't need to duplicate them in `db/schema.ts` or run the Better Auth CLI.
|
|
255
158
|
|
|
256
159
|
MySQL stores OAuth access, refresh, and ID tokens as unbounded text. Existing direct-deploy MySQL apps should run `void db generate` once after upgrading to widen earlier `varchar(255)` token columns. Void platform deployments apply the same safe widening automatically.
|
|
257
|
-
|
|
258
|
-
## Unsupported Modes
|
|
259
|
-
|
|
260
|
-
Void-managed Better Auth is supported only for Cloudflare Void apps in v1.
|
|
261
|
-
|
|
262
|
-
- meta-framework mode should use Better Auth's official framework integrations directly
|
|
263
|
-
- `target: "node" | "bun" | "deno"` should use Better Auth directly
|
|
@@ -4,26 +4,11 @@ outline: deep
|
|
|
4
4
|
|
|
5
5
|
# D1 (SQLite)
|
|
6
6
|
|
|
7
|
-
[Cloudflare D1](https://developers.cloudflare.com/d1/) is
|
|
8
|
-
|
|
9
|
-
## When to Use D1
|
|
10
|
-
|
|
11
|
-
D1 is the default database for Void apps and a great choice when you want zero-config database access:
|
|
12
|
-
|
|
13
|
-
- **Prototyping:** start building immediately with no external database to provision
|
|
14
|
-
- **Read-heavy apps:** optimized for read workloads at the edge
|
|
15
|
-
- **Small to medium scale:** a good fit for apps that do not need advanced SQL features such as stored procedures or complex joins
|
|
16
|
-
- **Simplicity:** Void creates, migrates, and manages the D1 instance for you
|
|
17
|
-
|
|
18
|
-
For write-heavy workloads, complex queries, or connecting to existing infrastructure, see [PostgreSQL](./postgresql).
|
|
19
|
-
|
|
20
|
-
## Configuration
|
|
21
|
-
|
|
22
|
-
None. D1 is the default dialect, so you can start by defining your schema and querying.
|
|
7
|
+
[Cloudflare D1](https://developers.cloudflare.com/d1/) is Void's default SQLite database. Start with a [schema](../database.md#schema-definition); Void manages the database locally and when you deploy.
|
|
23
8
|
|
|
24
9
|
## Read replication
|
|
25
10
|
|
|
26
|
-
Void enables [D1 read replication](https://developers.cloudflare.com/d1/best-practices/read-replication/) when it provisions a database.
|
|
11
|
+
Void enables [D1 read replication](https://developers.cloudflare.com/d1/best-practices/read-replication/) when it provisions a database. To enable it on an existing database, run `void deploy --platform cloudflare --provision`. Queries through `db` from `void/db` use a D1 session for each Void request, so reads can run near the request and later queries in that request see at least the same data. Framework handlers without Void's request scope start each database operation on the primary. `createDb` starts a replica-capable session for the binding you pass it.
|
|
27
12
|
|
|
28
13
|
Replicas can lag between requests. Authentication session checks start on the primary so a revoked session is not accepted because of replica lag. If another read must start with the latest primary data, use `env.DB.withSession('first-primary')` from `cloudflare:workers`. Other query libraries and raw D1 calls need their own `withSession()` to use replicas; a bare D1 binding reads from the primary.
|
|
29
14
|
|
|
@@ -35,45 +20,15 @@ To store local data outside `.void`, set `voidPlugin({ persistTo: 'local-state'
|
|
|
35
20
|
|
|
36
21
|
## Migrations & Prototyping
|
|
37
22
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Prototyping with `push`
|
|
41
|
-
|
|
42
|
-
During development, use `void db push` to apply your schema directly to the local D1 database. It does not create migration files.
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
void db push
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
This diffs your Drizzle schema against the local database and applies the changes immediately. It's fast and ideal for iterating on your schema before committing to a migration.
|
|
49
|
-
|
|
50
|
-
### Production migrations
|
|
51
|
-
|
|
52
|
-
When you're ready to ship, generate SQL migration files from your schema:
|
|
23
|
+
Use `void db push` to apply schema changes locally without creating migration files. Before deploying, generate and commit migrations:
|
|
53
24
|
|
|
54
|
-
```
|
|
25
|
+
```sh
|
|
55
26
|
void db generate
|
|
27
|
+
void db migrate # apply locally
|
|
28
|
+
void deploy # apply remotely and deploy
|
|
56
29
|
```
|
|
57
30
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
To apply pending migrations locally:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
void db migrate
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Deploy Workflow
|
|
67
|
-
|
|
68
|
-
When you run `void deploy`:
|
|
69
|
-
|
|
70
|
-
1. The app is built
|
|
71
|
-
2. Migration files are collected from `db/migrations/`
|
|
72
|
-
3. If the schema has drifted ahead of the migrations, you're prompted to generate and commit the new migrations
|
|
73
|
-
4. Pending migrations run against the remote D1 database
|
|
74
|
-
5. The new worker goes live
|
|
75
|
-
|
|
76
|
-
Deploys always go through migration files. `push` is only for local development.
|
|
31
|
+
See [Database commands](../../reference/cli/database.md#database) for the full workflow.
|
|
77
32
|
|
|
78
33
|
## Batch Operations
|
|
79
34
|
|
|
@@ -91,7 +46,7 @@ await db.batch([
|
|
|
91
46
|
|
|
92
47
|
## Alternative Query Layers
|
|
93
48
|
|
|
94
|
-
|
|
49
|
+
Use `env.DB` from `cloudflare:workers` with another query library or the raw D1 API:
|
|
95
50
|
|
|
96
51
|
### Kysely
|
|
97
52
|
|
|
@@ -114,5 +69,5 @@ const { results } = await env.DB.prepare('SELECT * FROM users WHERE id = ?').bin
|
|
|
114
69
|
Void still handles binding inference and deployment regardless of which query layer you use.
|
|
115
70
|
|
|
116
71
|
::: warning ⚠️ Meta framework limitation
|
|
117
|
-
|
|
72
|
+
Nuxt and SvelteKit do not support `cloudflare:workers` imports during local development. Use `void/db` or your framework's binding access API.
|
|
118
73
|
:::
|
|
@@ -4,7 +4,7 @@ outline: deep
|
|
|
4
4
|
|
|
5
5
|
# MySQL
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Connect your MySQL database through [Cloudflare Hyperdrive](https://developers.cloudflare.com/hyperdrive/), then define tables and query them with Drizzle. Void configures the connection and applies your migrations when you deploy.
|
|
8
8
|
|
|
9
9
|
## Configure
|
|
10
10
|
|
|
@@ -36,25 +36,17 @@ This connects directly to your Postgres database during local Vite development.
|
|
|
36
36
|
|
|
37
37
|
### 3. Deploy
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
For a Void platform, deploy prompts for the connection string if needed. You can also set it with `void db set-url`. For direct Cloudflare deploys, export the production `DATABASE_URL` in your shell.
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
Your project uses PostgreSQL. Enter your connection string:
|
|
43
|
-
> postgresql://user:password@host:5432/mydb?sslmode=require
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Void provisions Hyperdrive and records its config ID. The connection string isn't written to `void.config.ts`, `void.lock.json`, or generated Worker config.
|
|
47
|
-
Both `postgres://` and `postgresql://` URLs are supported, including provider-supplied query strings such as `?sslmode=require`.
|
|
48
|
-
|
|
49
|
-
For a linked Void project, you can also configure the connection with `void db set-url`. For a direct Cloudflare deploy, export the production `DATABASE_URL` in your shell.
|
|
41
|
+
Void provisions Hyperdrive without saving the connection string in project config. Both `postgres://` and `postgresql://` URLs are supported, including provider query strings such as `?sslmode=require`.
|
|
50
42
|
|
|
51
43
|
## Schema Definition
|
|
52
44
|
|
|
53
|
-
|
|
45
|
+
Import schema helpers from `void/schema-pg`:
|
|
54
46
|
|
|
55
47
|
```ts
|
|
56
48
|
// db/schema.ts
|
|
57
|
-
import { pgTable, serial, text, timestamp, boolean
|
|
49
|
+
import { pgTable, serial, text, timestamp, boolean } from 'void/schema-pg';
|
|
58
50
|
|
|
59
51
|
export const users = pgTable('users', {
|
|
60
52
|
id: serial('id').primaryKey(),
|
|
@@ -86,20 +78,7 @@ void db status
|
|
|
86
78
|
|
|
87
79
|
The main difference is that PostgreSQL supports **transactional DDL**. Each migration is wrapped in `BEGIN` and `COMMIT`, so a failure rolls back the whole migration instead of leaving the database half-updated.
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
When deploying a PostgreSQL project to a Void platform:
|
|
92
|
-
|
|
93
|
-
1. The app is built
|
|
94
|
-
2. Migration files are collected from `db/migrations/`
|
|
95
|
-
3. If Hyperdrive hasn't been provisioned yet, you're prompted for the connection string
|
|
96
|
-
4. Pending migrations run inside the deployed worker via Hyperdrive
|
|
97
|
-
5. The new worker goes live
|
|
98
|
-
|
|
99
|
-
When deploying to your own account with `void deploy --platform cloudflare`, export the production
|
|
100
|
-
connection string as `DATABASE_URL`. Void uses it to provision Hyperdrive and apply the checked-in
|
|
101
|
-
migrations transactionally before it uploads the Worker. The connection string is not written to
|
|
102
|
-
`void.config.ts`, `void.lock.json`, or the generated Worker config.
|
|
81
|
+
`void deploy` applies pending migrations before making the new version live. See [Deployment](../deployment.md).
|
|
103
82
|
|
|
104
83
|
## Updating the Connection String
|
|
105
84
|
|
|
@@ -39,16 +39,13 @@ Define your tables in TypeScript, then query them with `db` from `void/db`. Void
|
|
|
39
39
|
|
|
40
40
|
## Choosing a Dialect
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Choose a database during `void init`, or set `database` in `void.config.ts`:
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
| Managed by | Void | Bring your own database | Bring your own database |
|
|
50
|
-
| Best for | Prototypes, read-heavy apps | Complex queries, existing Postgres | Existing MySQL infrastructure |
|
|
51
|
-
| Connection | Automatic D1 binding | Hyperdrive | Hyperdrive |
|
|
44
|
+
| | [D1 (SQLite)](./database/d1) | [PostgreSQL](./database/postgresql) | [MySQL](./database/mysql) |
|
|
45
|
+
| ---------- | ---------------------------- | ----------------------------------- | ------------------------- |
|
|
46
|
+
| Config | Default | `"database": "pg"` | `"database": "mysql"` |
|
|
47
|
+
| Managed by | Void | Bring your own database | Bring your own database |
|
|
48
|
+
| Connection | Automatic D1 binding | Hyperdrive | Hyperdrive |
|
|
52
49
|
|
|
53
50
|
## Schema Definition
|
|
54
51
|
|
|
@@ -235,25 +232,15 @@ const usersWithPosts = await db.query.users.findMany({
|
|
|
235
232
|
});
|
|
236
233
|
```
|
|
237
234
|
|
|
238
|
-
The user schema is automatically loaded into the `db` instance via a Vite plugin, so relational queries work out of the box.
|
|
239
|
-
|
|
240
235
|
::: warning ⚠️ Nuxt and Analog limitations
|
|
241
|
-
Nuxt and Analog use
|
|
236
|
+
In Nuxt and Analog, use the query builder (`db.select().from(table)`). The `db.query.*` relational API is not available in these frameworks.
|
|
242
237
|
:::
|
|
243
238
|
|
|
244
239
|
## Seeding
|
|
245
240
|
|
|
246
241
|
Use `void db seed` to reset your local database, re-apply migrations, and then run a seed file.
|
|
247
242
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
1. `db/seed.ts`
|
|
251
|
-
2. `db/seed.mts`
|
|
252
|
-
3. `db/seed.js`
|
|
253
|
-
4. `db/seed.mjs`
|
|
254
|
-
5. `db/seed.sql`
|
|
255
|
-
|
|
256
|
-
If more than one default seed file exists, pass `--file <path>` explicitly.
|
|
243
|
+
Use `db/seed.ts` for a programmatic seed or `db/seed.sql` for SQL. JavaScript and `.mts` / `.mjs` files also work. If more than one seed file exists, choose one with `--file <path>`.
|
|
257
244
|
|
|
258
245
|
### Programmatic seeding
|
|
259
246
|
|
|
@@ -274,7 +261,7 @@ export default defineSeed<typeof import('./schema')>(async ({ db, schema }) => {
|
|
|
274
261
|
|
|
275
262
|
The seed context includes:
|
|
276
263
|
|
|
277
|
-
- `dialect`: `"sqlite"` or `"
|
|
264
|
+
- `dialect`: `"sqlite"`, `"postgresql"`, or `"mysql"`
|
|
278
265
|
- `db`: a Drizzle instance for the local database
|
|
279
266
|
- `schema`: the exports from your `db/schema.ts` or `db/schema/` modules
|
|
280
267
|
|
|
@@ -288,25 +275,14 @@ INSERT INTO messages (text) VALUES ('Hello from SQL');
|
|
|
288
275
|
|
|
289
276
|
## Schema-Derived Validators
|
|
290
277
|
|
|
291
|
-
|
|
278
|
+
Derive request validators from your tables with `void/drizzle-zod`, `void/drizzle-valibot`, or `void/drizzle-arktype`. Add the validator after your table definition:
|
|
292
279
|
|
|
293
280
|
::: code-group
|
|
294
281
|
|
|
295
282
|
```ts [Zod]
|
|
296
283
|
// db/schema.ts
|
|
297
|
-
import { sqliteTable, text, integer } from 'void/schema-d1';
|
|
298
|
-
import { sql } from 'void/db';
|
|
299
284
|
import { createInsertSchema } from 'void/drizzle-zod';
|
|
300
285
|
|
|
301
|
-
export const users = sqliteTable('users', {
|
|
302
|
-
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
303
|
-
name: text('name').notNull(),
|
|
304
|
-
email: text('email').notNull(),
|
|
305
|
-
createdAt: text('created_at')
|
|
306
|
-
.notNull()
|
|
307
|
-
.default(sql`(datetime('now'))`),
|
|
308
|
-
});
|
|
309
|
-
|
|
310
286
|
export const insertUserSchema = createInsertSchema(users, {
|
|
311
287
|
name: (schema) => schema.min(1),
|
|
312
288
|
email: (schema) => schema.email(),
|
|
@@ -315,20 +291,9 @@ export const insertUserSchema = createInsertSchema(users, {
|
|
|
315
291
|
|
|
316
292
|
```ts [Valibot]
|
|
317
293
|
// db/schema.ts
|
|
318
|
-
import { sqliteTable, text, integer } from 'void/schema-d1';
|
|
319
|
-
import { sql } from 'void/db';
|
|
320
294
|
import { createInsertSchema } from 'void/drizzle-valibot';
|
|
321
295
|
import { pipe, minLength, email } from 'valibot';
|
|
322
296
|
|
|
323
|
-
export const users = sqliteTable('users', {
|
|
324
|
-
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
325
|
-
name: text('name').notNull(),
|
|
326
|
-
email: text('email').notNull(),
|
|
327
|
-
createdAt: text('created_at')
|
|
328
|
-
.notNull()
|
|
329
|
-
.default(sql`(datetime('now'))`),
|
|
330
|
-
});
|
|
331
|
-
|
|
332
297
|
export const insertUserSchema = createInsertSchema(users, {
|
|
333
298
|
name: (schema) => pipe(schema, minLength(1)),
|
|
334
299
|
email: (schema) => pipe(schema, email()),
|
|
@@ -337,20 +302,9 @@ export const insertUserSchema = createInsertSchema(users, {
|
|
|
337
302
|
|
|
338
303
|
```ts [ArkType]
|
|
339
304
|
// db/schema.ts
|
|
340
|
-
import { sqliteTable, text, integer } from 'void/schema-d1';
|
|
341
|
-
import { sql } from 'void/db';
|
|
342
305
|
import { createInsertSchema } from 'void/drizzle-arktype';
|
|
343
306
|
import { type } from 'arktype';
|
|
344
307
|
|
|
345
|
-
export const users = sqliteTable('users', {
|
|
346
|
-
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
347
|
-
name: text('name').notNull(),
|
|
348
|
-
email: text('email').notNull(),
|
|
349
|
-
createdAt: text('created_at')
|
|
350
|
-
.notNull()
|
|
351
|
-
.default(sql`(datetime('now'))`),
|
|
352
|
-
});
|
|
353
|
-
|
|
354
308
|
export const insertUserSchema = createInsertSchema(users, {
|
|
355
309
|
name: type('string > 0'),
|
|
356
310
|
email: type('string.email'),
|
|
@@ -397,35 +351,29 @@ npm install arktype
|
|
|
397
351
|
|
|
398
352
|
## CLI Commands
|
|
399
353
|
|
|
400
|
-
| Command | Purpose
|
|
401
|
-
| ------------------ |
|
|
402
|
-
| `void db push` | Apply schema
|
|
403
|
-
| `void db
|
|
404
|
-
| `void db
|
|
405
|
-
| `void db
|
|
406
|
-
| `void db
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
| `void db execute` | Run ad-hoc SQL against local DB (`--file <path>`) |
|
|
410
|
-
| `void db studio` | Open Drizzle Studio for the local database |
|
|
411
|
-
| `void db export` | Dump local DB as SQL (`--output`, `--no-data`, `--no-schema`) |
|
|
412
|
-
| `void db set-url` | Update the PostgreSQL or MySQL connection string for deployment |
|
|
413
|
-
|
|
414
|
-
See the [CLI reference](../reference/cli.md#database) for details.
|
|
354
|
+
| Command | Purpose |
|
|
355
|
+
| ------------------ | ---------------------------------------------------- |
|
|
356
|
+
| `void db push` | Apply schema changes locally without migration files |
|
|
357
|
+
| `void db generate` | Generate SQL migrations |
|
|
358
|
+
| `void db migrate` | Apply pending migrations locally |
|
|
359
|
+
| `void db status` | Check schema drift and pending migrations |
|
|
360
|
+
| `void db seed` | Reset the local database and run a seed file |
|
|
361
|
+
|
|
362
|
+
See the [CLI reference](../reference/cli/database.md#database) for connection setup, SQL execution, Studio, exports, and other commands.
|
|
415
363
|
|
|
416
364
|
## Scaffolding
|
|
417
365
|
|
|
418
366
|
The `void gen model` command generates dialect-appropriate `sqliteTable`, `pgTable`, or `mysqlTable` definitions.
|
|
419
367
|
|
|
420
368
|
```bash
|
|
421
|
-
void gen model
|
|
369
|
+
void gen model posts title:string body:text published:boolean
|
|
422
370
|
```
|
|
423
371
|
|
|
424
372
|
This creates:
|
|
425
373
|
|
|
426
|
-
1. `db/schema/
|
|
427
|
-
2. Updates `db/schema.ts` with `export * from "./schema/
|
|
374
|
+
1. `db/schema/posts.ts`: a Drizzle table definition with `id`, `createdAt`, `updatedAt`, and your columns
|
|
375
|
+
2. Updates `db/schema.ts` with `export * from "./schema/posts"`
|
|
428
376
|
3. `routes/api/posts/index.ts`: `GET` for list and `POST` for insert with validation
|
|
429
377
|
4. `routes/api/posts/[id].ts`: `GET` by id with `404` handling
|
|
430
378
|
|
|
431
|
-
See the [CLI reference](../reference/cli.md#code-generation) for the full list of generators.
|
|
379
|
+
See the [CLI reference](../reference/cli/generate.md#code-generation) for the full list of generators.
|