void 0.21.9 → 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-DZZGK80W.mjs → account-cmd-C84Ee8cO.mjs} +5 -5
- 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-B_CeugBw.mjs → auth-link-CioEg6uY.mjs} +5 -5
- package/dist/{auth-router-BgEFRuvZ.mjs → auth-router-BsR981d4.mjs} +5 -5
- package/dist/{better-auth-shared-rsBGBvWJ.mjs → better-auth-shared-hy6RPh9W.mjs} +13 -2
- package/dist/{build-cmd-Dpt0jd-x.mjs → build-cmd-LzvNJORH.mjs} +19 -7
- package/dist/{cache-7_UeZdTk.mjs → cache-C4MvnrMH.mjs} +4 -4
- package/dist/{cancel-deploy-D23R1RXT.mjs → cancel-deploy-abUxpP2n.mjs} +4 -4
- package/dist/{cf-build-output-CGT03qCD.mjs → cf-build-output-BPqOT964.mjs} +141 -63
- package/dist/cf-build-output-_0HNWysu.mjs +2 -0
- package/dist/cli/cli.mjs +114 -460
- package/dist/cli/cloudflare-operation-process.mjs +1103 -0
- 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-QTl6ko_D.mjs → client-RV8NVeB8.mjs} +165 -21
- package/dist/{cloudflare-auth-C4_GPZr0.mjs → cloudflare-auth-Qdc7tw8F.mjs} +41 -43
- package/dist/{cloudflare-cmd-bSmZ1d5L.mjs → cloudflare-cmd-BcrVyTmJ.mjs} +9 -10
- package/dist/cloudflare-config-Bktvwtpf.mjs +182 -0
- package/dist/{cloudflare-connect-jAwacxxP.mjs → cloudflare-connect-B8uPZ4nx.mjs} +4 -4
- package/dist/{cloudflare-operations-BipGMJ5O.mjs → cloudflare-operations-AiWashgg.mjs} +1 -1
- package/dist/{cloudflare-operations-sMZXpk_S.mjs → cloudflare-operations-fxHb-byx.mjs} +118 -203
- package/dist/{preset-UHj9ARyP.mjs → cloudflare-process-B-wekeR6.mjs} +93 -6
- package/dist/{config-CF69HgXc.d.mts → config-BMHb8RCj.d.mts} +2 -2
- package/dist/{config-CafTW6Cz.mjs → config-Br_JZD6u.mjs} +2 -7
- package/dist/config-C_XRIPx2.mjs +89 -0
- package/dist/{config-s7Xj7tPb.mjs → config-CyQ-wVd7.mjs} +1 -1
- package/dist/config-entry.d.mts +1 -1
- package/dist/{config-write-BSduPMY8.mjs → config-write-B1f88wJA.mjs} +1 -1
- package/dist/{connect-BsUSRzln.mjs → connect-Bd4kJd9U.mjs} +6 -6
- package/dist/{create-project-BniEV0OW.mjs → create-project-Boczwj5r.mjs} +1 -1
- package/dist/{create-project-DBfFSZKY.mjs → create-project-bMf6ffLZ.mjs} +9 -5
- package/dist/{db-hRrvZaq_.mjs → db-8uG64XLl.mjs} +26 -26
- package/dist/{delete-D6dZ9B6B.mjs → delete-NvbiyeJf.mjs} +4 -4
- package/dist/{deploy-WaAQez1O.mjs → deploy-DzAIwqNU.mjs} +944 -607
- package/dist/{deploy-DDz7c8LK.mjs → deploy-bjXdFCtn.mjs} +1 -1
- package/dist/{dist-BR1quN_w.mjs → dist-AoCzRTJE.mjs} +226 -60
- package/dist/{dist-C5fND3R0.mjs → dist-BuDuKZJv.mjs} +1 -1
- package/dist/{dist-Dn6nn2IU.mjs → dist-CTBk70IR.mjs} +42 -42
- package/dist/{domain-Dmhvb2oU.mjs → domain-y5Tvydvo.mjs} +5 -5
- package/dist/{email-DFi-s2t4.mjs → email-B3umsW75.mjs} +15 -30
- package/dist/{env-Csi-tMbT.mjs → env-BS6qYHDb.mjs} +6 -6
- package/dist/{env-public-D_6u46fX.d.mts → env-public-BX_r8HR6.d.mts} +2 -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-Dz3X1Qab.mjs → gen-B580--vC.mjs} +5 -5
- package/dist/gen-BVaUUumi.mjs +2 -0
- package/dist/{github-cmd-BED3_9JD.mjs → github-cmd-v45BdfKX.mjs} +6 -8
- package/dist/{handler-BXJTXd02.d.mts → handler-CZ4nAylQ.d.mts} +2 -1
- package/dist/{headers-BOg_velo.mjs → headers-DWi2IXWx.mjs} +1 -1
- package/dist/help-DofyZuY7.mjs +2 -0
- package/dist/{help-DC7gdz7L.mjs → help-daGKjXGk.mjs} +268 -666
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +305 -1490
- package/dist/info-B97bTX9N.mjs +113 -0
- package/dist/{init-WO0JlPx8.mjs → init-Bvy7zrBo.mjs} +51 -20
- package/dist/limits-Bq5LG8Id.d.mts +27 -0
- package/dist/limits-Cjuk2VPm.mjs +68 -0
- package/dist/{link-CsHOinF7.mjs → link-CDqqCjFl.mjs} +5 -5
- package/dist/{list-CDb-4bZ1.mjs → list-CZj0dzKY.mjs} +5 -5
- package/dist/{live-CKiJilLr.d.mts → live-Chw1eIMv.d.mts} +1 -1
- package/dist/{local-d1-CC8sKFGu.mjs → local-d1-2CMnpuW_.mjs} +2 -2
- package/dist/login-DYt_An22.mjs +2 -0
- package/dist/{login-DvqXsfGs.mjs → login-UZKFM_u7.mjs} +5 -5
- package/dist/{logs-BdfiOezj.mjs → logs-CUZ6t9t3.mjs} +5 -5
- package/dist/migrate-8_2u55MD.mjs +2 -0
- package/dist/{migrate-B8KuoYsO.mjs → migrate-DHul7PRV.mjs} +5 -4
- package/dist/{node-BM43oz4G.mjs → node-BkyRWRx8.mjs} +2 -2
- package/dist/operator-args-CLgKGlwU.mjs +690 -0
- package/dist/{operator-cmd-03819ATr.mjs → operator-cmd-DBA6dl0m.mjs} +69 -23
- package/dist/output-Dm_A4Tbv.mjs +81 -0
- 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 +3 -3
- package/dist/pages/islands-plugin.d.mts +16 -6
- package/dist/pages/islands-plugin.mjs +2 -2
- 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/{output-CCH48AMM.mjs → picocolors-BTps1_gs.mjs} +2 -76
- 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-z92h63q5.mjs → platform-auth-config-B56E9YP1.mjs} +4 -4
- package/dist/{platform-auth-protection-DeE3yr2R.mjs → platform-auth-protection-BDWO_aER.mjs} +3 -3
- package/dist/{platform-auth-recovery-o_340Ixx.mjs → platform-auth-recovery-1gg4CSRe.mjs} +4 -4
- package/dist/{platform-cmd-C4ZV3Vpy.mjs → platform-cmd-Bt-1w6pY.mjs} +1 -1
- package/dist/{platform-cmd-DNl8WosH.mjs → platform-cmd-DMcQStSc.mjs} +26 -5
- package/dist/{platform-domain-CU1JtJkW.mjs → platform-domain-BNkcz0OB.mjs} +36 -9
- package/dist/{platform-lifecycle-Bc047IeT.mjs → platform-lifecycle-9OyBALhH.mjs} +850 -276
- package/dist/{platform-lifecycle-Bs2qx1E3.mjs → platform-lifecycle-BE6C_jxh.mjs} +1 -1
- package/dist/{platform-management-CVpGI9Y5.mjs → platform-management-CjwLVQwN.mjs} +59 -11
- package/dist/{platform-management-C8tt6D8h.mjs → platform-management-CnyTdcWX.mjs} +1 -1
- package/dist/platform-plans-config-BNGKGr4P.mjs +359 -0
- package/dist/{platform-recovery-dvUaptLr.mjs → platform-recovery-D6KSpuFm.mjs} +2 -2
- package/dist/{plugin-inference-BMfKRSqE.mjs → plugin-inference-CXWnn79A.mjs} +174 -64
- package/dist/{prepare-DyZ-Yok5.mjs → prepare-B5Mkic5u.mjs} +3 -3
- package/dist/{prepare-C3kt3Rst.mjs → prepare-DOsL0CC9.mjs} +4 -20
- package/dist/prepare-cgvDMtSb.mjs +2 -0
- package/dist/{project-cmd-B44I8J_W.mjs → project-cmd-CNzrqvBv.mjs} +30 -16
- package/dist/{project-team-BkbYIsXN.mjs → project-team-DQOWPfQT.mjs} +4 -4
- package/dist/{project-token-C8xEEQnB.mjs → project-token-CTDYU0Cc.mjs} +4 -4
- package/dist/project-zero-trust-BNAkW-_0.mjs +63 -0
- package/dist/{protocol-ZH3jP4a7.d.mts → protocol-CjF_iI9X.d.mts} +2 -2
- package/dist/protocol-U7bfjHmA.mjs +331 -0
- package/dist/{provision-DNtrtaVD.mjs → provision-C4ORE7G7.mjs} +1 -1
- package/dist/{provision-BhreDAOS.mjs → provision-CJFgTZY8.mjs} +111 -215
- package/dist/{requests-DFyhBMaf.mjs → requests-MhxYnau8.mjs} +4 -4
- package/dist/resource-name-C7LVpcRm.mjs +11 -0
- package/dist/{rollback-DHHxXZiS.mjs → rollback-CJ6iSDoU.mjs} +5 -5
- 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 +3 -0
- package/dist/runtime/sandbox-container.mjs +2 -0
- package/dist/runtime/sandbox.d.mts +4 -32
- package/dist/runtime/sandbox.mjs +151 -75
- 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-XZAqzFlG.d.mts +52 -0
- package/dist/sandbox-container-Bo0eiFKz.d.mts +73 -0
- package/dist/sandbox-container-C6ItmVuN.mjs +281 -0
- package/dist/{scan-4tfN-PSn.mjs → scan-C7okrLyM.mjs} +4 -35
- package/dist/{secret-DN9sSNiV.mjs → secret-Dli5fP0B.mjs} +6 -6
- package/dist/{skills-O6FUaizK.mjs → skills-D1II1Juz.mjs} +1 -1
- package/dist/{sse-BaC1jXko.mjs → sse-CQNaDFFV.mjs} +6 -3
- package/dist/{subcommand-prompt-BuGYkAkC.mjs → subcommand-prompt-CY1C4fvl.mjs} +2 -2
- package/dist/validate-Dq_L3s0S.mjs +2 -0
- package/dist/{validate-CIUwFpjB.mjs → validate-ctOrgiS3.mjs} +2 -1
- package/dist/{wrangler-BymcxrRa.mjs → wrangler-7K-bW_DL.mjs} +14 -235
- package/dist/{ws-BwcqizuH.d.mts → ws-CL1w7GXU.d.mts} +13 -2
- package/package.json +48 -33
- package/sandbox.Dockerfile +4 -0
- package/schema.json +10 -22
- package/skills/migrate-vite-cloudflare-to-void/SKILL.md +34 -157
- package/skills/void/SKILL.md +50 -133
- 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 +6 -19
- package/skills/void/docs/guide/edge/rewrites.md +56 -284
- package/skills/void/docs/guide/edge/static-assets.md +23 -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 +189 -0
- package/skills/void/docs/guide/platform/development/local.md +2 -2
- 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 +31 -3
- package/skills/void/docs/guide/platform/installation/first-deployment.md +6 -0
- package/skills/void/docs/guide/platform/installation/maintenance.md +3 -1
- package/skills/void/docs/guide/platform/installation/prerequisites.md +21 -16
- package/skills/void/docs/guide/platform/installation/setup.md +9 -5
- package/skills/void/docs/guide/platform/installation/uninstall.md +17 -2
- package/skills/void/docs/guide/platform-administration.md +2 -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 +78 -41
- 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 +33 -1621
- package/skills/void/docs/reference/config.md +26 -32
- 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/cli/cf-compat.mjs +0 -968
- package/dist/client-4cDVv7BO.mjs +0 -2
- package/dist/gen-Vnv2f65C.mjs +0 -2
- package/dist/help-DQMfeKMz.mjs +0 -2
- package/dist/login-DFQk7rbW.mjs +0 -2
- package/dist/migrate-TsHGBnDA.mjs +0 -2
- package/dist/plan-BEZ8VJW0.mjs +0 -256
- package/dist/plan-DpuOr14e.mjs +0 -2
- package/dist/prepare-BZXkjdNe.mjs +0 -2
- package/dist/validate-EKmJWxmy.mjs +0 -2
- /package/dist/cli/{cf-compat.d.mts → cloudflare-operation-process.d.mts} +0 -0
|
@@ -10,16 +10,6 @@ Set `target` in `void.config.ts` to build for Node.js, Bun, or Deno. You can run
|
|
|
10
10
|
{ "target": "node" }
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
## Supported Targets
|
|
14
|
-
|
|
15
|
-
| Target | Server | Static Assets |
|
|
16
|
-
| -------- | ------------------------------------------------------------------------- | -------------------------------- |
|
|
17
|
-
| `"node"` | [`@hono/node-server`](https://github.com/honojs/node-server) | `@hono/node-server/serve-static` |
|
|
18
|
-
| `"bun"` | [`Bun.serve()`](https://bun.sh/docs/api/http) | `hono/bun` |
|
|
19
|
-
| `"deno"` | [`Deno.serve()`](https://docs.deno.com/runtime/fundamentals/http_server/) | `hono/deno` |
|
|
20
|
-
|
|
21
|
-
All three produce the same project structure and use the same Hono-based routing. The only difference is the HTTP server and static file middleware.
|
|
22
|
-
|
|
23
13
|
## Getting Started
|
|
24
14
|
|
|
25
15
|
### 1. Configure the target
|
|
@@ -43,7 +33,7 @@ npm install @hono/node-server
|
|
|
43
33
|
npx vite dev
|
|
44
34
|
```
|
|
45
35
|
|
|
46
|
-
The
|
|
36
|
+
The development server reloads routes and pages when you edit them.
|
|
47
37
|
|
|
48
38
|
### 4. Build and run
|
|
49
39
|
|
|
@@ -68,7 +58,7 @@ deno run -A dist/ssr/index.js
|
|
|
68
58
|
|
|
69
59
|
Run these commands from your app directory. The server listens on `PORT` (env variable) or `3000` by default.
|
|
70
60
|
|
|
71
|
-
|
|
61
|
+
Deploy `dist/ssr` and `dist/client` together.
|
|
72
62
|
|
|
73
63
|
## Build Output
|
|
74
64
|
|
|
@@ -120,7 +110,7 @@ The following imports are **not available** with a non-CF target and produce a c
|
|
|
120
110
|
|
|
121
111
|
If you need a database or storage, use an external provider and connect via standard Node.js libraries.
|
|
122
112
|
|
|
123
|
-
|
|
113
|
+
WebSocket route files (`*.ws.ts`) require Cloudflare. You can still use the `void/ws` browser client to connect to a separately hosted WebSocket server.
|
|
124
114
|
|
|
125
115
|
### No cron job runtime
|
|
126
116
|
|
|
@@ -128,11 +118,11 @@ You can still define [cron jobs](../guide/jobs.md) in `crons/` and they will com
|
|
|
128
118
|
|
|
129
119
|
### No inbound email
|
|
130
120
|
|
|
131
|
-
Inbound
|
|
121
|
+
[Inbound email handlers](../guide/email/receiving.md#inbound) and `sendEmail` require Cloudflare. Use an external mail provider on other targets.
|
|
132
122
|
|
|
133
123
|
### No prerendering
|
|
134
124
|
|
|
135
|
-
[
|
|
125
|
+
[Edge prerendering](../guide/edge/prerendering.md) requires Cloudflare. Build-time [static generation](../guide/ssg.md) is available on all targets.
|
|
136
126
|
|
|
137
127
|
### No `void deploy`
|
|
138
128
|
|
|
@@ -149,60 +139,6 @@ Void warns and ignores these Cloudflare-specific `void.config.ts` fields on othe
|
|
|
149
139
|
|
|
150
140
|
If you enable auth through `void/auth`, `void/client`, or `auth.ts`, Void fails the build for non-CF targets. Use Better Auth directly for Node/Bun/Deno deployments.
|
|
151
141
|
|
|
152
|
-
## Example: API + Pages
|
|
153
|
-
|
|
154
|
-
A typical Node.js Void app with API routes and React pages:
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
my-app/
|
|
158
|
-
pages/
|
|
159
|
-
layout.tsx
|
|
160
|
-
index.tsx
|
|
161
|
-
index.server.ts
|
|
162
|
-
about.tsx
|
|
163
|
-
about.server.ts
|
|
164
|
-
routes/
|
|
165
|
-
api/
|
|
166
|
-
hello.ts
|
|
167
|
-
package.json
|
|
168
|
-
vite.config.ts
|
|
169
|
-
void.config.ts
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
// void.config.ts
|
|
174
|
-
{ "target": "node" }
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
```ts
|
|
178
|
-
// vite.config.ts
|
|
179
|
-
import { defineConfig } from 'vite';
|
|
180
|
-
import { voidPlugin } from 'void';
|
|
181
|
-
import { voidReact } from '@void/react/plugin';
|
|
182
|
-
|
|
183
|
-
export default defineConfig({
|
|
184
|
-
plugins: [voidPlugin(), voidReact()],
|
|
185
|
-
});
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
```ts
|
|
189
|
-
// routes/api/hello.ts
|
|
190
|
-
import { defineHandler } from 'void';
|
|
191
|
-
|
|
192
|
-
export const GET = defineHandler((c) => {
|
|
193
|
-
return c.json({ message: 'Hello from Node.js!' });
|
|
194
|
-
});
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
# Development
|
|
199
|
-
npx vite dev
|
|
200
|
-
|
|
201
|
-
# Production
|
|
202
|
-
npx vite build
|
|
203
|
-
node dist/ssr/index.js
|
|
204
|
-
```
|
|
205
|
-
|
|
206
142
|
## Programmatic Usage
|
|
207
143
|
|
|
208
144
|
Since `app.js` exports the Hono app, you can import it into a custom server:
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Authentication {#auth}
|
|
6
|
+
|
|
7
|
+
Imported from `"void"` or `"void/auth"`. Client-side helpers imported from `"void/client"`.
|
|
8
|
+
|
|
9
|
+
## `defineAuth(config)` {#defineauth-config}
|
|
10
|
+
|
|
11
|
+
Advanced escape hatch for customizing Void's Better Auth config.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineAuth } from 'void/auth';
|
|
15
|
+
|
|
16
|
+
export default defineAuth(({ defaults }) => ({
|
|
17
|
+
...defaults,
|
|
18
|
+
trustedOrigins: ['https://example.com'],
|
|
19
|
+
}));
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Signature:**
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
function defineAuth(config: VoidAuthConfig): VoidAuthConfig;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## `getUser()` {#getuser}
|
|
29
|
+
|
|
30
|
+
Returns the current authenticated user, or `null` when no user is present.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { getUser } from 'void/auth';
|
|
34
|
+
|
|
35
|
+
const user = getUser();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Signature:**
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
function getUser(): AuthUser | null;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## `getSession()` {#getsession}
|
|
45
|
+
|
|
46
|
+
Returns the current Better Auth request state, or `null`.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { getSession } from 'void/auth';
|
|
50
|
+
|
|
51
|
+
const state = getSession();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Signature:**
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
function getSession(): AuthState | null;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## `requireAuth(c)` {#requireauth-c}
|
|
61
|
+
|
|
62
|
+
Extracts the authenticated user from the request context. Throws a 401 `HTTPException` if no session is present.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { defineHandler } from 'void';
|
|
66
|
+
import { requireAuth } from 'void/auth';
|
|
67
|
+
|
|
68
|
+
export const GET = defineHandler((c) => {
|
|
69
|
+
const user = requireAuth(c);
|
|
70
|
+
return { email: user.email };
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Signature:**
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
function requireAuth(c: CloudContext): AuthUser;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## `AuthUser` {#authuser}
|
|
81
|
+
|
|
82
|
+
Better Auth user shape re-exported by Void.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
interface AuthUser {
|
|
86
|
+
id: string;
|
|
87
|
+
email: string;
|
|
88
|
+
emailVerified: boolean;
|
|
89
|
+
name: string;
|
|
90
|
+
image?: string | null;
|
|
91
|
+
createdAt: Date;
|
|
92
|
+
updatedAt: Date;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## `AuthSession` {#authsession}
|
|
97
|
+
|
|
98
|
+
Better Auth session shape re-exported by Void.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
interface AuthSession {
|
|
102
|
+
id: string;
|
|
103
|
+
token: string;
|
|
104
|
+
userId: string;
|
|
105
|
+
expiresAt: Date;
|
|
106
|
+
createdAt: Date;
|
|
107
|
+
updatedAt: Date;
|
|
108
|
+
ipAddress?: string | null;
|
|
109
|
+
userAgent?: string | null;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## `AuthState` {#authstate}
|
|
114
|
+
|
|
115
|
+
Combined authenticated request state:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
interface AuthState {
|
|
119
|
+
user: AuthUser;
|
|
120
|
+
session: AuthSession;
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## `auth` {#auth-1}
|
|
125
|
+
|
|
126
|
+
Imported from `"void/client"`. This is a ready-to-use Better Auth client instance preconfigured with `basePath: "/api/auth"`.
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { auth } from 'void/client';
|
|
130
|
+
|
|
131
|
+
await auth.signIn.email({ email, password });
|
|
132
|
+
await auth.signOut();
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The exact client methods come from Better Auth. In pages apps, Void automatically chooses the framework-specific Better Auth client package when available.
|
|
136
|
+
|
|
137
|
+
For regular SPA apps that use Void for API/file routes without Void Pages mode, import the framework-specific client explicitly:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
import { auth } from 'void/client/react';
|
|
141
|
+
// or: 'void/client/vue'
|
|
142
|
+
// or: 'void/client/svelte'
|
|
143
|
+
// or: 'void/client/solid'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Those subpaths keep the same `fetch`, `fetchStream`, and auth exports as `void/client`, but bind `auth` and `createAuthClient` to Better Auth's framework package.
|
|
147
|
+
|
|
148
|
+
## `createAuthClient` {#createauthclient}
|
|
149
|
+
|
|
150
|
+
Imported from `"void/client"`. Re-export of Better Auth's `createAuthClient` for advanced usage.
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { createAuthClient } from 'void/client';
|
|
154
|
+
|
|
155
|
+
const auth = createAuthClient({ basePath: '/api/auth' });
|
|
156
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Fetch Client {#fetch-client}
|
|
6
|
+
|
|
7
|
+
Imported from `"void/client"`.
|
|
8
|
+
|
|
9
|
+
## `fetch(path, options?)` {#fetch-path-options}
|
|
10
|
+
|
|
11
|
+
Type-safe fetch client for calling your API routes from client code, built on top of [ofetch](https://github.com/unjs/ofetch). Route paths and return types are inferred from the generated `RouteMap`.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { fetch } from 'void/client';
|
|
15
|
+
|
|
16
|
+
// Types are fully inferred from your route handlers
|
|
17
|
+
const users = await fetch('/api/users');
|
|
18
|
+
const user = await fetch('/api/users/:id', {
|
|
19
|
+
params: { id: '1' },
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Signature:**
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
function fetch<P extends keyof RouteMap, M extends MethodsOf<P>>(
|
|
27
|
+
path: P,
|
|
28
|
+
options?: FetchOptions<P, M>,
|
|
29
|
+
): Promise<OutputOf<P, M>>;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Options:**
|
|
33
|
+
|
|
34
|
+
| Option | Type | Description |
|
|
35
|
+
| --------- | ------------------------ | ---------------------------------------------------------- |
|
|
36
|
+
| `method` | `string` | HTTP method. Defaults to `"GET"`. |
|
|
37
|
+
| `body` | `unknown` | Request body (auto-serialized as JSON). |
|
|
38
|
+
| `query` | `Record<string, string>` | Query string parameters. |
|
|
39
|
+
| `params` | `Record<string, string>` | URL path parameters (`:id` segments). |
|
|
40
|
+
| `headers` | `HeadersInit` | Additional request headers. |
|
|
41
|
+
| `signal` | `AbortSignal` | Abort signal. |
|
|
42
|
+
| `baseURL` | `string` | Base URL prepended to the path. Useful for external calls. |
|
|
43
|
+
| `retry` | `number` | Number of retry attempts (ofetch default: 1 for GET). |
|
|
44
|
+
| `timeout` | `number` | Request timeout in milliseconds. |
|
|
45
|
+
|
|
46
|
+
Returns the parsed JSON response body, or `undefined` for 204 responses. Throws `FetchError` on non-2xx responses.
|
|
47
|
+
|
|
48
|
+
## `FetchError` {#fetcherror}
|
|
49
|
+
|
|
50
|
+
Error class thrown by `fetch` on non-2xx responses.
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { fetch, FetchError } from 'void/client';
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
await fetch('/api/users/:id', { params: { id: '999' } });
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (e instanceof FetchError) {
|
|
59
|
+
console.log(e.status); // 404
|
|
60
|
+
console.log(e.response); // raw Response
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Properties:**
|
|
66
|
+
|
|
67
|
+
| Property | Type | Description |
|
|
68
|
+
| ---------- | ---------- | ------------------------------------ |
|
|
69
|
+
| `status` | `number` | HTTP status code. |
|
|
70
|
+
| `response` | `Response` | The raw `Response` object. |
|
|
71
|
+
| `data` | `unknown` | Parsed response body (if available). |
|
|
72
|
+
|
|
73
|
+
## Differences from Native `fetch` {#differences-from-native-fetch}
|
|
74
|
+
|
|
75
|
+
The typed client is built on [ofetch](https://github.com/unjs/ofetch) with a typed route layer on top. Key differences from native `fetch`:
|
|
76
|
+
|
|
77
|
+
| Behavior | Native `fetch` | `void/client` `fetch` |
|
|
78
|
+
| ---------------------- | ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
+
| **Return type** | `Promise<Response>`, so you call `.json()` yourself | `Promise<T>`, which auto-parses JSON and returns the typed result directly (`undefined` for `204`) |
|
|
80
|
+
| **Error handling** | Resolves on any HTTP status; you check `response.ok` | Throws `FetchError` on non-2xx responses |
|
|
81
|
+
| **URL construction** | Raw URL string | Route path with `:param` interpolation from `options.params` + query string from `options.query` |
|
|
82
|
+
| **Body serialization** | Manual `JSON.stringify()` + `Content-Type` header | Auto-serializes `options.body` as JSON and sets `Content-Type: application/json` |
|
|
83
|
+
| **Type safety** | Accepts any URL or method | Constrains paths to `RouteMap` keys and methods to those defined per route. Invalid combinations fail at compile time. |
|
|
84
|
+
| **Retry** | None | Auto-retries on 408, 429, and 5xx (configurable via `retry` option) |
|
|
85
|
+
| **Timeout** | None | Configurable via `timeout` option |
|
|
86
|
+
|
|
87
|
+
`headers` and `signal` are passed through to the underlying fetch unchanged.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Database and Seeding {#database}
|
|
6
|
+
|
|
7
|
+
Imported from `"void/db"`. The `db` export is a [Drizzle ORM](https://orm.drizzle.team) instance for the configured database dialect: [Cloudflare D1](https://developers.cloudflare.com/d1/) by default, PostgreSQL with `"database": "pg"`, or MySQL with `"database": "mysql"`.
|
|
8
|
+
|
|
9
|
+
## `db` {#db}
|
|
10
|
+
|
|
11
|
+
Default Drizzle instance, pre-wired with your schema from `db/schema.ts`.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { db } from 'void/db';
|
|
15
|
+
import { users } from '@schema';
|
|
16
|
+
|
|
17
|
+
const allUsers = await db.select().from(users).all();
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`db` uses your configured dialect and schema.
|
|
21
|
+
|
|
22
|
+
- D1 projects resolve the `DB` binding and expose `DrizzleD1Database<Schema>`.
|
|
23
|
+
- PostgreSQL projects use `DATABASE_URL` during local development and Hyperdrive's `connectionString` in production, exposing `NodePgDatabase<Schema>`.
|
|
24
|
+
- MySQL projects use the same connection sources and expose `MySql2Database<Schema>`.
|
|
25
|
+
|
|
26
|
+
## `createDb(database)` {#createdb-database}
|
|
27
|
+
|
|
28
|
+
Creates a Drizzle instance for the active dialect.
|
|
29
|
+
|
|
30
|
+
For D1 projects, pass a specific D1 binding. Use this when you have multiple D1 databases or need a non-default binding.
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { createDb } from 'void/db';
|
|
34
|
+
import { env } from 'cloudflare:workers';
|
|
35
|
+
|
|
36
|
+
const db = createDb(env.MY_OTHER_DB);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For PostgreSQL and MySQL projects, pass a connection string.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createDb } from 'void/db';
|
|
43
|
+
|
|
44
|
+
const db = createDb('postgres://user:password@host:5432/app');
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Signature:**
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// D1
|
|
51
|
+
function createDb(d1: D1Database): DrizzleD1Database<Schema>;
|
|
52
|
+
|
|
53
|
+
// PostgreSQL
|
|
54
|
+
function createDb(connectionString: string): NodePgDatabase<Schema>;
|
|
55
|
+
|
|
56
|
+
// MySQL
|
|
57
|
+
function createDb(connectionString: string): MySql2Database<Schema>;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Query Operators {#query-operators}
|
|
61
|
+
|
|
62
|
+
`void/db` re-exports commonly used [Drizzle operators](https://orm.drizzle.team/docs/operators) so you never need to depend on `drizzle-orm` directly:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { db, eq, and, or, desc, like, inArray, sql } from 'void/db';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Full list:** `sql`, `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `and`, `or`, `not`, `desc`, `asc`, `like`, `ilike`, `notLike`, `inArray`, `notInArray`, `isNull`, `isNotNull`, `between`, `notBetween`, `exists`, `notExists`, `count`, `sum`, `avg`, `min`, `max`.
|
|
69
|
+
|
|
70
|
+
## Seeding {#seeding}
|
|
71
|
+
|
|
72
|
+
Imported from `"void/seed"`.
|
|
73
|
+
|
|
74
|
+
### `defineSeed(fn)` {#defineseed-fn}
|
|
75
|
+
|
|
76
|
+
Identity helper for programmatic seed modules used by `void db seed`.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { defineSeed } from 'void/seed';
|
|
80
|
+
|
|
81
|
+
export default defineSeed<typeof import('./schema')>(async ({ db, schema }) => {
|
|
82
|
+
await db.insert(schema.users).values([
|
|
83
|
+
{ name: 'Alice', email: 'alice@example.com' },
|
|
84
|
+
{ name: 'Bob', email: 'bob@example.com' },
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The callback receives:
|
|
90
|
+
|
|
91
|
+
- `dialect`: `"sqlite"`, `"postgresql"`, or `"mysql"`
|
|
92
|
+
- `db`: a local Drizzle instance for the active dialect
|
|
93
|
+
- `schema`: the exports from `db/schema.ts` or `db/schema/`
|
|
94
|
+
|
|
95
|
+
Seed modules can export either `default` or a named `seed` function.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Durable State and WebSockets {#durable-state}
|
|
6
|
+
|
|
7
|
+
Imported from `"void/durable"`. See [Durable State](../../guide/durable-state.md) for the complete file convention and deployment support.
|
|
8
|
+
|
|
9
|
+
## `defineDurableState(definition)` {#definedurablestate-definition}
|
|
10
|
+
|
|
11
|
+
Defines a typed, persisted Durable Object state machine. The returned object must be the default export of a module under `durable-objects/`; named-export the same object for typed RPC calls elsewhere in the app.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
function defineDurableState<TState, TEnv, TMethods>(definition: {
|
|
15
|
+
name?: string;
|
|
16
|
+
initialState: TState | ((env: TEnv) => TState | Promise<TState>);
|
|
17
|
+
version?: number;
|
|
18
|
+
migrations?: Array<{
|
|
19
|
+
version: number;
|
|
20
|
+
migrate(state: unknown): TState | Promise<TState>;
|
|
21
|
+
}>;
|
|
22
|
+
methods: TMethods;
|
|
23
|
+
fetch?: (context, request: Request) => Response | Promise<Response>;
|
|
24
|
+
alarm?: (context) => void | Promise<void>;
|
|
25
|
+
storageKey?: string;
|
|
26
|
+
}): DurableStateApi<TMethods>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`DurableStateApi` exposes `class`, `get(name)`, `get(namespace, name)`, `getById(id)`, and `getById(namespace, id)`. Stubs returned by the lookup helpers contain the definition's methods with their argument types preserved and return values wrapped in `Promise`.
|
|
30
|
+
|
|
31
|
+
`name` optionally fixes the persistent resource identity instead of deriving it from the filename. Run `void info` and pin the displayed name before renaming a deployed definition. Keep instance names passed to `get()` unchanged. See the [migration flow](../../guide/durable-state.md#rename-a-file-while-keeping-its-state).
|
|
32
|
+
|
|
33
|
+
## WebSockets {#websockets}
|
|
34
|
+
|
|
35
|
+
Imported from `"void/ws"`. `defineRoom()` adds shared-room helpers to hook contexts; `defineWebSocket()` supplies a connection's socket helpers. Both require `messages.client` and `messages.server` Standard Schema validators and support the hooks described in the [WebSocket guide](../../guide/websockets.md).
|
|
36
|
+
|
|
37
|
+
Both helpers accept these optional resource settings:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
name?: string;
|
|
41
|
+
key?: (context: { params: Record<string, string> }) => string;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`name` fixes the Worker class and binding identity. Without it, Void derives the identity from the route file. Run `void info` before moving a deployed route and pin its displayed name.
|
|
45
|
+
|
|
46
|
+
`key` selects the route instance and its `ctx.id`. Without it, routes use parameter names and values in route order (`room=general`, or `default` without parameters). A callback must return a stable string synchronously. When renaming parameters, preserve the complete old key to retain state. See [moving routes](../../guide/websockets.md#move-a-route-while-keeping-its-state) and [renaming parameters](../../guide/websockets.md#rename-a-route-parameter).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Environment Variables {#environment}
|
|
6
|
+
|
|
7
|
+
Imported from `"void/env"`.
|
|
8
|
+
|
|
9
|
+
## `defineEnv(schema)` {#defineenv-schema}
|
|
10
|
+
|
|
11
|
+
Register an env schema and return the typed [`env`](#env) proxy. Void auto-discovers `env.ts`, imports it during dev/build/deploy, generates `.void/env.d.ts`, validates production secrets before deploy, and validates values at worker boot.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { defineEnv, string, number, oneOf, url } from 'void/env';
|
|
15
|
+
|
|
16
|
+
export default defineEnv({
|
|
17
|
+
STRIPE_KEY: string(),
|
|
18
|
+
PORT: number().default(3000),
|
|
19
|
+
NODE_ENV: oneOf(['development', 'production']),
|
|
20
|
+
VITE_PUBLIC_URL: url(),
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## `env` {#env}
|
|
25
|
+
|
|
26
|
+
Typed runtime proxy for declared env keys. Unknown keys and bindings pass through as `unknown`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { env } from 'void/env';
|
|
30
|
+
|
|
31
|
+
const port = env.PORT;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Schema helpers {#schema-helpers}
|
|
35
|
+
|
|
36
|
+
`void/env` includes Standard Schema-compatible helpers: `string()`, `number()`, `boolean()`, `url()`, `email()`, `oneOf([...])`, and `json<T>()`. Each helper supports `.optional()` and `.default(value)`.
|
|
37
|
+
|
|
38
|
+
Non-client keys are server values and use remote secret storage in production. `VITE_*` keys are public build-time client values. Invalid input is redacted uniformly; storage is not selected with schema modifiers.
|
|
39
|
+
|
|
40
|
+
## Types {#types-1}
|
|
41
|
+
|
|
42
|
+
`void/env` also provides global Cloudflare environment types:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
/// <reference types="void/env" />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Declares the `Cloudflare.Env` namespace with `DB`, `KV`, `STORAGE`, `AI`, and `SANDBOX` binding types.
|
|
49
|
+
|
|
50
|
+
For handler context variables such as `c.set()` and `c.get()`, augment [`CloudContextVariables`](./types.md#cloudcontextvariables). This is separate from `Cloudflare.Env`, which types worker bindings. Framework adapters such as `@void/vue`, `@void/react`, and `@void/svelte` also augment `CloudContextVariables` to add the `shared` key used by `useShared()`.
|