@builtbyfriends/bwf 0.0.0-stage → 1.9.2
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/AGENTS_TEMPLATE.md +4 -0
- package/LICENSE +22 -0
- package/README.md +48 -2
- package/dist/account-cmd-Ddt8lGeL.mjs +45 -0
- package/dist/agents-BLiMq9E1.mjs +113 -0
- package/dist/application-analysis-C9Ck2Yeg.mjs +1498 -0
- package/dist/application-routing-DbR-W5lG.mjs +25 -0
- package/dist/atomic-write-DA6eD1Kp.mjs +17 -0
- package/dist/auth-BKsUmWbT.d.mts +77 -0
- package/dist/auth-DkvoW5hB.mjs +33 -0
- package/dist/auth-aKyIWkdS.mjs +1 -0
- package/dist/auth-client-6-Ft9i9T.d.mts +5 -0
- package/dist/auth-client-DwCdwKbw.mjs +5 -0
- package/dist/auth-client-react-CJdeErvM.mjs +5 -0
- package/dist/auth-client-react-DvQLe5Zb.d.mts +5 -0
- package/dist/auth-link-CCl-hJol.mjs +26 -0
- package/dist/auth-migrations-DDeifS3v.mjs +206 -0
- package/dist/auth-router-BG74WFUf.mjs +66 -0
- package/dist/auth-xnkmpZUl.mjs +311 -0
- package/dist/base64-ikl9yBy3.mjs +15 -0
- package/dist/better-auth-shared-Br6TNaYJ.mjs +473 -0
- package/dist/better-auth-shared-CsBNvPOU.d.mts +56 -0
- package/dist/build-cmd-BnZezraT.mjs +153 -0
- package/dist/build-output-dir-Clj_unKN.mjs +402 -0
- package/dist/cancel-deploy-DKAj5U1Z.mjs +57 -0
- package/dist/cf-access-Bhz9wX6p.mjs +131 -0
- package/dist/cf-access-CUP5L08W.mjs +67 -0
- package/dist/cf-build-output-DA6uJomQ.mjs +1 -0
- package/dist/cf-build-output-DNQTwMNU.mjs +438 -0
- package/dist/cf-command-values-2kOtxMo1.mjs +26 -0
- package/dist/cf-config-migrate-COOCi4Ge.mjs +330 -0
- package/dist/cf-worker-settings-CIh4t_yG.mjs +41 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +88 -0
- package/dist/cli/cloudflare-operation-process.d.mts +1 -0
- package/dist/cli/cloudflare-operation-process.mjs +1284 -0
- package/dist/cli/env-schema-probe.d.mts +43 -0
- package/dist/cli/env-schema-probe.mjs +165 -0
- package/dist/cli-main-BfYf6fnB.mjs +1846 -0
- package/dist/client-D3D5RM5h.mjs +940 -0
- package/dist/client-VF2Nzc7Z.mjs +1 -0
- package/dist/cloudflare-auth-DzkU9H6r.mjs +152 -0
- package/dist/cloudflare-cmd-Bm6UhzAQ.mjs +59 -0
- package/dist/cloudflare-config-i8yanry0.mjs +186 -0
- package/dist/cloudflare-connect-B4ItSbJi.mjs +55 -0
- package/dist/cloudflare-operations-BcK849ue.mjs +1 -0
- package/dist/cloudflare-operations-DGF7xH7O.mjs +627 -0
- package/dist/cloudflare-process-tThIjEB2.mjs +309 -0
- package/dist/cloudflare-user-output-CqONaAbP.mjs +19 -0
- package/dist/collect-8i0wU63d.mjs +1 -0
- package/dist/collect-C6Blu9yw.mjs +48 -0
- package/dist/config-CN_RFRkS.mjs +86 -0
- package/dist/config-D5G-Tx6o.mjs +1 -0
- package/dist/config-DOaFIK3w.mjs +88 -0
- package/dist/config-entry.d.mts +202 -0
- package/dist/config-entry.mjs +6 -0
- package/dist/config-tNx0HlFv.mjs +516 -0
- package/dist/connect-CSNWKLzB.mjs +84 -0
- package/dist/create-project-B35ux-LA.mjs +126 -0
- package/dist/create-project-tJ1KwNss.mjs +1 -0
- package/dist/database-provider-DkZo4VwN.mjs +5 -0
- package/dist/database-provider.d.mts +25 -0
- package/dist/database-provider.mjs +1 -0
- package/dist/db-SOv4E9wr.mjs +1735 -0
- package/dist/delete-BSKI7V23.mjs +65 -0
- package/dist/deploy-BCSQoKC0.mjs +2 -0
- package/dist/deploy-CWJ3JJs_.mjs +6512 -0
- package/dist/deploy.d.mts +31 -0
- package/dist/deploy.mjs +118 -0
- package/dist/dev-inbox-I0nqTCdf.mjs +216 -0
- package/dist/discover-DJPmQcL5.mjs +36 -0
- package/dist/discover-EVuydEoM.mjs +1 -0
- package/dist/dist-B6eN80gc.mjs +1612 -0
- package/dist/dist-Cp4b1_T9.mjs +1 -0
- package/dist/dist-DMYe8CZJ.mjs +48 -0
- package/dist/dist-STQXl8ck.mjs +1878 -0
- package/dist/domain-BJaAbxuQ.mjs +149 -0
- package/dist/dotenv-4NdUCXbB.mjs +156 -0
- package/dist/drizzle-DqVFXtlc.mjs +306 -0
- package/dist/drizzle-Ds5P0n-S.mjs +1 -0
- package/dist/edge.d.mts +2 -0
- package/dist/edge.mjs +1 -0
- package/dist/email-C_ATvNIG.mjs +2865 -0
- package/dist/email-cloudflare-oXk2G1G3.mjs +854 -0
- package/dist/email-protocol-CZ0bAkI8.mjs +81 -0
- package/dist/email-rIfZgVAB.mjs +742 -0
- package/dist/env-BGTu3KWZ.mjs +73 -0
- package/dist/env-DUyTzroe.mjs +88 -0
- package/dist/env-Dl4Wggec.mjs +71 -0
- package/dist/env-helpers-BX0APszT.mjs +135 -0
- package/dist/env-helpers-U56xuFgL.d.mts +20 -0
- package/dist/env-mask-BsHxq3R8.mjs +46 -0
- package/dist/env-public-Cw_xPi1D.d.mts +119 -0
- package/dist/env-raw-Bo6TtrHU.mjs +41 -0
- package/dist/env-types-Bg-dTh8u.mjs +56 -0
- package/dist/env-validation-BlXzGgLZ.mjs +1 -0
- package/dist/env-validation-DeqFUSKg.mjs +488 -0
- package/dist/fetch-CBgyyhzm.d.mts +87 -0
- package/dist/fetch-error-DmlRM6e4.mjs +264 -0
- package/dist/fetch-stream-2GUN3YN1.mjs +102 -0
- package/dist/fetch-stream-bUXynOyZ.d.mts +32 -0
- package/dist/fetch-tpPiSK10.mjs +25 -0
- package/dist/gen-dc13IRXh.mjs +509 -0
- package/dist/gen-kQqhFyOP.mjs +1 -0
- package/dist/generate-BgtlYpKg.mjs +1 -0
- package/dist/generate-Da9mWKzU.mjs +80 -0
- package/dist/generated-wrangler-config-CoDaaFsA.mjs +17 -0
- package/dist/git-metadata-Cukp5kV5.mjs +82 -0
- package/dist/github-cmd-DT5Onu6E.mjs +690 -0
- package/dist/handler-B_ocHStk.d.mts +279 -0
- package/dist/handler-CNq7aSs1.mjs +161 -0
- package/dist/help-BK35YcRa.mjs +1946 -0
- package/dist/help-DaRezBj7.mjs +1 -0
- package/dist/inbound-CqubE-9T.d.mts +311 -0
- package/dist/inbound-lHugZPuK.mjs +509 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.mjs +4163 -0
- package/dist/info-CLQoCenb.mjs +109 -0
- package/dist/init-CXanf5ck.mjs +2486 -0
- package/dist/limits-CMmYT2l8.d.mts +16 -0
- package/dist/limits-D27Lp6FP.mjs +46 -0
- package/dist/link-DinwJnon.mjs +52 -0
- package/dist/list-B1WAE9Wt.mjs +130 -0
- package/dist/live-KkEeda1Z.d.mts +105 -0
- package/dist/live-saC8barp.mjs +410 -0
- package/dist/load-user-env-g0ahkZcj.mjs +34 -0
- package/dist/local-d1-bUoAtFUe.mjs +103 -0
- package/dist/log-JDnPc0cF.mjs +23 -0
- package/dist/login-BUzyiyHV.mjs +1 -0
- package/dist/login-Dbv_T3Ru.mjs +87 -0
- package/dist/logs-BjMJooJQ.mjs +129 -0
- package/dist/migrate-DjW9_-sS.mjs +1 -0
- package/dist/migrate-DtcfKqPW.mjs +125 -0
- package/dist/migration-handler-22qiuWPq.mjs +469 -0
- package/dist/migration-handler-Bb2BJh6g.d.mts +38 -0
- package/dist/mime-BMUN_QKG.mjs +1004 -0
- package/dist/mysql-migration-sql-CNuBSqdx.mjs +239 -0
- package/dist/neon-CJzQSycr.mjs +52 -0
- package/dist/node-tfv-3v0V.mjs +64 -0
- package/dist/operator-ai-logging-Ay7M4KWw.mjs +121 -0
- package/dist/operator-args-BiGmSlZx.mjs +722 -0
- package/dist/operator-auth-DdYZYEkO.mjs +47 -0
- package/dist/operator-client-DBujdELO.mjs +82 -0
- package/dist/operator-cmd-BsHKYJYt.mjs +1 -0
- package/dist/operator-cmd-DTIkOAnP.mjs +443 -0
- package/dist/output-Bb34lF0w.mjs +173 -0
- package/dist/output-CVolXKC1.mjs +1 -0
- package/dist/package-BX_giUBX.mjs +1444 -0
- package/dist/package-json-DvS6IFRv.mjs +43 -0
- package/dist/pg-DoyPxa_X.mjs +15 -0
- package/dist/picocolors-D1NxSLw-.mjs +71 -0
- package/dist/plan-BHNt1QhK.mjs +1 -0
- package/dist/plan-DX4_-OM5.mjs +58 -0
- package/dist/platform-args-C-DyuCNX.mjs +1 -0
- package/dist/platform-args-CyeQWaZ7.mjs +538 -0
- package/dist/platform-auth-config-BfXqKSyZ.mjs +371 -0
- package/dist/platform-auth-protection-5FR6qoP_.mjs +231 -0
- package/dist/platform-auth-recovery-B5ZlqA8K.mjs +309 -0
- package/dist/platform-cmd-CcFDxtrl.mjs +1 -0
- package/dist/platform-cmd-ChXeBrRH.mjs +193 -0
- package/dist/platform-discovery-Bxg9aZXU.mjs +40 -0
- package/dist/platform-domain-CwatS3cz.mjs +256 -0
- package/dist/platform-lifecycle-0cXTmMsh.mjs +8928 -0
- package/dist/platform-lifecycle-BcoBAMux.mjs +1 -0
- package/dist/platform-management-6Wbdbob5.mjs +1607 -0
- package/dist/platform-management-hhnczOzr.mjs +1 -0
- package/dist/platform-plans-config-CkbUKFpm.mjs +447 -0
- package/dist/platform-recovery-DgIwlqB-.mjs +96 -0
- package/dist/platform-registry-x1m9HBxf.mjs +450 -0
- package/dist/platform-runtime-logs-kkoiYFpF.mjs +72 -0
- package/dist/platform-setup-DX8y_6Kh.mjs +306 -0
- package/dist/prepare-B9mB47T5.mjs +84 -0
- package/dist/prepare-DNIq07so.mjs +13 -0
- package/dist/prepare-LHkyJqxi.mjs +1 -0
- package/dist/project-CC7eN00D.mjs +141 -0
- package/dist/project-DcSd4BeI.mjs +1 -0
- package/dist/project-cmd-BydRwr-x.mjs +109 -0
- package/dist/project-paths-iXHKRTTQ.mjs +159 -0
- package/dist/project-slug-BUy0lmyR.mjs +1 -0
- package/dist/project-slug-CO6ci9XG.mjs +7 -0
- package/dist/project-team-CvdLhDF2.mjs +129 -0
- package/dist/project-token-CwZdUEGu.mjs +70 -0
- package/dist/project-tsconfig-P9X952KG.mjs +98 -0
- package/dist/project-zero-trust-CKDoPdN1.mjs +64 -0
- package/dist/providers-Cd3c7wi0.mjs +64 -0
- package/dist/providers-Df69hb_X.d.mts +5 -0
- package/dist/provision-BA59NCPO.mjs +1 -0
- package/dist/provision-C90fULHJ.mjs +1814 -0
- package/dist/queues-Bc3FsBQT.d.mts +5 -0
- package/dist/r2-conditions-DSLmkiR5.mjs +60 -0
- package/dist/requests-DNhfyF3l.mjs +52 -0
- package/dist/resolve-project-BCsAMDRA.mjs +47 -0
- package/dist/resolve-project-DhU9_lIo.mjs +1 -0
- package/dist/resource-name-DlJ9QXzg.mjs +10 -0
- package/dist/response-HmNjB30w.mjs +29 -0
- package/dist/rollback-wi6WK5T6.mjs +150 -0
- package/dist/rolldown-runtime-uD8oG6U2.mjs +24 -0
- package/dist/route-types-CRWhr93D.mjs +592 -0
- package/dist/route-url-BIDZT78M.mjs +58 -0
- package/dist/route-url-Bla3Upsy.d.mts +42 -0
- package/dist/routes-stub.d.mts +24 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/routing-assets-CSheDWWM.mjs +54 -0
- package/dist/rpc-DcByS_q0.d.mts +39 -0
- package/dist/rpc-DtxIN9Tv.mjs +19 -0
- package/dist/runner-CPerdjIl.mjs +163 -0
- package/dist/runner-CUNtS5x7.mjs +1 -0
- package/dist/runner-mysql-BjSoQ-mW.mjs +1 -0
- package/dist/runner-mysql-BmTI2EiF.mjs +145 -0
- package/dist/runner-pg-2pjltt0t.mjs +1 -0
- package/dist/runner-pg-mYc75KfH.mjs +61 -0
- package/dist/runtime/ai.d.mts +50 -0
- package/dist/runtime/ai.mjs +455 -0
- package/dist/runtime/auth-client-react.d.mts +2 -0
- package/dist/runtime/auth-client-react.mjs +1 -0
- package/dist/runtime/auth-client.d.mts +2 -0
- package/dist/runtime/auth-client.mjs +1 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +1 -0
- package/dist/runtime/better-auth-mysql.d.mts +5 -0
- package/dist/runtime/better-auth-mysql.mjs +21 -0
- package/dist/runtime/better-auth-pg.d.mts +5 -0
- package/dist/runtime/better-auth-pg.mjs +21 -0
- package/dist/runtime/better-auth.d.mts +6 -0
- package/dist/runtime/better-auth.mjs +22 -0
- package/dist/runtime/client-react.d.mts +5 -0
- package/dist/runtime/client-react.mjs +5 -0
- package/dist/runtime/client.d.mts +5 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-mysql.d.mts +2 -0
- package/dist/runtime/db-mysql.mjs +1 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +36 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/durable.d.mts +64 -0
- package/dist/runtime/durable.mjs +165 -0
- package/dist/runtime/email/testing.d.mts +108 -0
- package/dist/runtime/email/testing.mjs +268 -0
- package/dist/runtime/email-protocol.d.mts +25 -0
- package/dist/runtime/email-protocol.mjs +1 -0
- package/dist/runtime/email.d.mts +26 -0
- package/dist/runtime/email.mjs +524 -0
- package/dist/runtime/env-public-client.d.mts +19 -0
- package/dist/runtime/env-public-client.mjs +55 -0
- package/dist/runtime/env-public.d.mts +4 -0
- package/dist/runtime/env-public.mjs +277 -0
- package/dist/runtime/env.d.mts +12 -0
- package/dist/runtime/env.mjs +1 -0
- package/dist/runtime/fetch-server.d.mts +6 -0
- package/dist/runtime/fetch-server.mjs +29 -0
- package/dist/runtime/fetch-stream.d.mts +3 -0
- package/dist/runtime/fetch-stream.mjs +3 -0
- package/dist/runtime/fetch.d.mts +2 -0
- package/dist/runtime/fetch.mjs +3 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +1 -0
- package/dist/runtime/kv.d.mts +45 -0
- package/dist/runtime/kv.mjs +103 -0
- package/dist/runtime/limits.d.mts +2 -0
- package/dist/runtime/limits.mjs +1 -0
- package/dist/runtime/live-client.d.mts +40 -0
- package/dist/runtime/live-client.mjs +282 -0
- package/dist/runtime/live-server.d.mts +11 -0
- package/dist/runtime/live-server.mjs +419 -0
- package/dist/runtime/live.d.mts +3 -0
- package/dist/runtime/live.mjs +1 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +57 -0
- package/dist/runtime/migration-handler-mysql.d.mts +2 -0
- package/dist/runtime/migration-handler-mysql.mjs +111 -0
- package/dist/runtime/migration-handler-pg.d.mts +2 -0
- package/dist/runtime/migration-handler-pg.mjs +94 -0
- package/dist/runtime/migration-handler.d.mts +2 -0
- package/dist/runtime/migration-handler.mjs +1 -0
- package/dist/runtime/procedure.d.mts +27 -0
- package/dist/runtime/procedure.mjs +36 -0
- package/dist/runtime/procedures.d.mts +24 -0
- package/dist/runtime/procedures.mjs +56 -0
- package/dist/runtime/queues.d.mts +2 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +11 -0
- package/dist/runtime/remote/binding-handler.mjs +227 -0
- package/dist/runtime/remote/index.d.mts +12 -0
- package/dist/runtime/remote/index.mjs +467 -0
- package/dist/runtime/response.d.mts +11 -0
- package/dist/runtime/response.mjs +1 -0
- package/dist/runtime/route-url.d.mts +2 -0
- package/dist/runtime/route-url.mjs +1 -0
- package/dist/runtime/routing.d.mts +53 -0
- package/dist/runtime/routing.mjs +425 -0
- package/dist/runtime/rpc-react.d.mts +16 -0
- package/dist/runtime/rpc-react.mjs +50 -0
- package/dist/runtime/rpc.d.mts +2 -0
- package/dist/runtime/rpc.mjs +1 -0
- package/dist/runtime/sandbox-container.d.mts +3 -0
- package/dist/runtime/sandbox-container.mjs +1 -0
- package/dist/runtime/sandbox.d.mts +5 -0
- package/dist/runtime/sandbox.mjs +196 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-mysql.d.mts +1 -0
- package/dist/runtime/schema-mysql.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +34 -0
- package/dist/runtime/seed.mjs +5 -0
- package/dist/runtime/sse-client.d.mts +31 -0
- package/dist/runtime/sse-client.mjs +42 -0
- package/dist/runtime/sse.d.mts +32 -0
- package/dist/runtime/sse.mjs +1 -0
- package/dist/runtime/storage.d.mts +4 -0
- package/dist/runtime/storage.mjs +13 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +1 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +297 -0
- package/dist/runtime/ws.d.mts +2 -0
- package/dist/runtime/ws.mjs +108 -0
- package/dist/sandbox-CWDjoEG2.d.mts +50 -0
- package/dist/sandbox-container-BqamdFCx.d.mts +73 -0
- package/dist/sandbox-container-d1AHLpgn.mjs +291 -0
- package/dist/secret-D5XrWshs.mjs +146 -0
- package/dist/skills-Dr3AjuBF.mjs +63 -0
- package/dist/sqlite-validation-CLJXXN93.mjs +24 -0
- package/dist/sse-CxR30yMF.mjs +174 -0
- package/dist/standard-schema-CuDawHOC.d.mts +40 -0
- package/dist/static-asset-marker-mWMX2dLa.mjs +38 -0
- package/dist/subcommand-prompt-B9yUo--u.mjs +370 -0
- package/dist/terminal-log-text-DNsWJREL.mjs +31 -0
- package/dist/types-D7-4tBu7.d.mts +1 -0
- package/dist/untrusted-env-lL7RkYiC.mjs +50 -0
- package/dist/validate-B-zsjhiz.mjs +162 -0
- package/dist/validate-DbqGdPPY.mjs +1 -0
- package/dist/validator-8-NZs2Xr.mjs +168 -0
- package/dist/version-metadata-DPhqnpaa.mjs +23 -0
- package/dist/wrangler-C3uyPadQ.mjs +1 -0
- package/dist/wrangler-TqTvJFWS.mjs +1452 -0
- package/dist/ws-DZRiIpYw.d.mts +137 -0
- package/dist/yarn-pnp-DgWbE7z5.mjs +91 -0
- package/docs/guide/ai.md +273 -0
- package/docs/guide/app-types.md +101 -0
- package/docs/guide/auth.md +255 -0
- package/docs/guide/database/d1.md +86 -0
- package/docs/guide/database/mysql.md +72 -0
- package/docs/guide/database/postgresql.md +94 -0
- package/docs/guide/database.md +454 -0
- package/docs/guide/deployment.md +124 -0
- package/docs/guide/durable-state.md +192 -0
- package/docs/guide/edge/headers.md +47 -0
- package/docs/guide/edge/redirects.md +85 -0
- package/docs/guide/edge/rewrites.md +119 -0
- package/docs/guide/edge/static-assets.md +94 -0
- package/docs/guide/email/domains.md +119 -0
- package/docs/guide/email/receiving.md +142 -0
- package/docs/guide/email/sending.md +262 -0
- package/docs/guide/email.md +23 -0
- package/docs/guide/env-vars.md +115 -0
- package/docs/guide/index.md +37 -0
- package/docs/guide/jobs.md +80 -0
- package/docs/guide/kv.md +100 -0
- package/docs/guide/live.md +181 -0
- package/docs/guide/platform/administration/access.md +165 -0
- package/docs/guide/platform/administration/connected-apps.md +84 -0
- package/docs/guide/platform/administration/email.md +169 -0
- package/docs/guide/platform/administration/operations.md +100 -0
- package/docs/guide/platform/administration/plans.md +156 -0
- package/docs/guide/platform/administration/projects.md +74 -0
- package/docs/guide/platform/administration/zero-trust.md +205 -0
- package/docs/guide/platform/development/local.md +122 -0
- package/docs/guide/platform/development/runtime.md +115 -0
- package/docs/guide/platform/development/schema-ci.md +44 -0
- package/docs/guide/platform/installation/ci.md +62 -0
- package/docs/guide/platform/installation/credentials.md +140 -0
- package/docs/guide/platform/installation/domains.md +120 -0
- package/docs/guide/platform/installation/first-deployment.md +95 -0
- package/docs/guide/platform/installation/maintenance.md +250 -0
- package/docs/guide/platform/installation/prerequisites.md +176 -0
- package/docs/guide/platform/installation/setup.md +300 -0
- package/docs/guide/platform/installation/uninstall.md +110 -0
- package/docs/guide/platform-administration.md +19 -0
- package/docs/guide/platform-development.md +16 -0
- package/docs/guide/procedures.md +48 -0
- package/docs/guide/project-collaboration.md +99 -0
- package/docs/guide/queues.md +149 -0
- package/docs/guide/quickstart.md +129 -0
- package/docs/guide/remote-dev.md +67 -0
- package/docs/guide/sandboxes.md +134 -0
- package/docs/guide/self-hosted-platform.md +45 -0
- package/docs/guide/server-routing.md +283 -0
- package/docs/guide/sse.md +174 -0
- package/docs/guide/storage.md +82 -0
- package/docs/guide/testing.md +64 -0
- package/docs/guide/type-safety.md +270 -0
- package/docs/guide/typed-fetch.md +98 -0
- package/docs/guide/websockets.md +230 -0
- package/docs/index.md +102 -0
- package/docs/integrations/agents.md +38 -0
- package/docs/integrations/cloudflare.md +241 -0
- package/docs/integrations/hono.md +127 -0
- package/docs/reference/api/auth.md +195 -0
- package/docs/reference/api/client.md +90 -0
- package/docs/reference/api/database.md +118 -0
- package/docs/reference/api/deploy.md +63 -0
- package/docs/reference/api/durable.md +47 -0
- package/docs/reference/api/env.md +51 -0
- package/docs/reference/api/handlers.md +189 -0
- package/docs/reference/api/plugin.md +40 -0
- package/docs/reference/api/resources.md +116 -0
- package/docs/reference/api/rewrites.md +111 -0
- package/docs/reference/api/types.md +126 -0
- package/docs/reference/api.md +71 -0
- package/docs/reference/cli/auth.md +87 -0
- package/docs/reference/cli/database.md +159 -0
- package/docs/reference/cli/deploy.md +117 -0
- package/docs/reference/cli/domains.md +42 -0
- package/docs/reference/cli/email.md +145 -0
- package/docs/reference/cli/generate.md +113 -0
- package/docs/reference/cli/github.md +181 -0
- package/docs/reference/cli/platform-config.md +93 -0
- package/docs/reference/cli/platform-email.md +81 -0
- package/docs/reference/cli/platform-installation.md +166 -0
- package/docs/reference/cli/platform-operations.md +90 -0
- package/docs/reference/cli/platform-users.md +159 -0
- package/docs/reference/cli/platform-zero-trust.md +60 -0
- package/docs/reference/cli/platform.md +78 -0
- package/docs/reference/cli/project.md +208 -0
- package/docs/reference/cli/secrets.md +79 -0
- package/docs/reference/cli/setup.md +88 -0
- package/docs/reference/cli.md +115 -0
- package/docs/reference/config.md +478 -0
- package/docs/reference/resource-inference.md +72 -0
- package/docs/reference/structure.md +138 -0
- package/package.json +389 -3
- package/sandbox.Dockerfile +4 -0
- package/schema.json +353 -0
- package/skills/bwf/SKILL.md +100 -0
- package/skills/migrate-vite-cloudflare-to-bwf/SKILL.md +53 -0
- package/templates/assets/bwf.svg +5 -0
- package/templates/assets/icons.svg +49 -0
- package/templates/assets/react.svg +1 -0
- package/templates/assets/stack.svg +35 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Add an endpoint by creating a file in routes/ and exporting a handler for each HTTP method.'
|
|
3
|
+
outline: deep
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Server Routing
|
|
7
|
+
|
|
8
|
+
Create a file in `routes/` to add an endpoint, and export a handler for each HTTP method you want to support. bwf uses [Hono](https://hono.dev) for routing and middleware.
|
|
9
|
+
|
|
10
|
+
## Route Files
|
|
11
|
+
|
|
12
|
+
Create route handlers in `routes/` using `.ts`, `.tsx`, `.js`, `.jsx`, `.mts`, or `.mjs`. Each file maps to a URL path based on its location in the filesystem:
|
|
13
|
+
|
|
14
|
+
<RoutesFileTree />
|
|
15
|
+
|
|
16
|
+
Dynamic segments use brackets: `[id]` becomes a route parameter and `[...slug]` becomes a catch-all. Prefix files or directories with `_` or `.` to exclude them from routing; `.well-known` remains available for standard discovery endpoints. Directories wrapped in parentheses like `(admin)` are route groups. They help organize files without changing the URL.
|
|
17
|
+
|
|
18
|
+
### Overlapping routes
|
|
19
|
+
|
|
20
|
+
When routes overlap, the most specific one handles the request. From left to right, static segments take priority over parameters. Catch-all routes run last:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
routes/
|
|
24
|
+
users/[id].ts → handles /users/about (users beats [lang])
|
|
25
|
+
[lang]/about.ts → handles /fr/about (about beats [slug])
|
|
26
|
+
[lang]/[slug].ts → handles /fr/contact
|
|
27
|
+
[...path].ts → handles URLs no other route matches
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Use one route for each pattern. `[id].ts` and `[slug].ts` match the same URLs; renaming a parameter doesn't change priority.
|
|
31
|
+
|
|
32
|
+
### Environment-only routes
|
|
33
|
+
|
|
34
|
+
Add a `.dev` or `.prod` suffix before the extension to include a route in only one environment:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
routes/
|
|
38
|
+
api/health.ts → always
|
|
39
|
+
api/debug.dev.ts → development only
|
|
40
|
+
api/metrics.prod.ts → production only
|
|
41
|
+
preview.dev.tsx → development only, with JSX
|
|
42
|
+
report.prod.jsx → production only, with JSX
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`.dev` routes run only in development; `.prod` routes run in builds, deployments, and production previews. A resource used only by `.dev` routes is not provisioned for production.
|
|
46
|
+
|
|
47
|
+
Suffixes apply in `routes/`, not in `middleware/`, `crons/`, or `queues/`. `bwf prepare` generates types for both environments.
|
|
48
|
+
|
|
49
|
+
Each file exports named HTTP method constants to handle specific methods:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// routes/api/hello.ts → GET /api/hello
|
|
53
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
54
|
+
|
|
55
|
+
export const GET = defineHandler((c) => {
|
|
56
|
+
return { message: 'Hello!', timestamp: Date.now() };
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
A file can export multiple methods:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
64
|
+
import { db } from '@builtbyfriends/bwf/db';
|
|
65
|
+
// routes/api/users/index.ts → GET + POST /api/users
|
|
66
|
+
import { users } from '@schema';
|
|
67
|
+
|
|
68
|
+
export const GET = defineHandler(async () => {
|
|
69
|
+
return await db.select().from(users);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const POST = defineHandler(async (c) => {
|
|
73
|
+
const body = await c.req.json();
|
|
74
|
+
await db.insert(users).values({ name: body.name });
|
|
75
|
+
return { created: true };
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`GET` handlers also answer `HEAD` requests automatically.
|
|
80
|
+
|
|
81
|
+
See [Database](./database.md) for queries with D1, PostgreSQL, or MySQL.
|
|
82
|
+
|
|
83
|
+
### JSX handlers
|
|
84
|
+
|
|
85
|
+
Use `.tsx` or `.jsx` when a server handler contains JSX. Route files use your app's JSX settings. In a React app, render JSX to HTML with React's server renderer:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
89
|
+
// routes/hello.tsx → GET /hello
|
|
90
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
91
|
+
|
|
92
|
+
export const GET = defineHandler((c) => c.html(renderToStaticMarkup(<h1>Hello!</h1>)));
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For API-only apps, add `hono` as a dependency and configure [Hono's JSX](https://hono.dev/docs/guides/jsx) in `vite.config.ts`:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import { bwfPlugin } from '@builtbyfriends/bwf';
|
|
99
|
+
// vite.config.ts
|
|
100
|
+
import { defineConfig } from 'vite-plus';
|
|
101
|
+
|
|
102
|
+
export default defineConfig({
|
|
103
|
+
oxc: { jsx: { runtime: 'automatic', importSource: 'hono/jsx' } },
|
|
104
|
+
plugins: [bwfPlugin()],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`c.html()` then takes the JSX directly:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
// routes/hello.tsx → GET /hello
|
|
112
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
113
|
+
|
|
114
|
+
export const GET = defineHandler((c) => c.html(<h1>Hello!</h1>));
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## `defineHandler`
|
|
118
|
+
|
|
119
|
+
The handler receives a Hono `Context` with typed Cloudflare bindings on `c.env` (see [Cloudflare](../integrations/cloudflare.md)). You can use the full Hono API (`c.json()`, `c.text()`, `c.header()`, etc.).
|
|
120
|
+
|
|
121
|
+
Return values are automatically converted:
|
|
122
|
+
|
|
123
|
+
- **object/array/number/boolean** → JSON response
|
|
124
|
+
- **`string`** → `text/html; charset=utf-8`
|
|
125
|
+
- **`null`/`undefined`** → `204 No Content`
|
|
126
|
+
- **`Response`** → returned as-is
|
|
127
|
+
|
|
128
|
+
## Validation
|
|
129
|
+
|
|
130
|
+
`defineHandler.withValidator()` adds input validation for `body`, `query`, and `params`. The recommended approach is to derive validators from your [Drizzle schema](./database.md#schema-derived-validators), which keeps validation in sync with the database.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
134
|
+
import { db } from '@builtbyfriends/bwf/db';
|
|
135
|
+
// routes/api/users/index.ts
|
|
136
|
+
import { users, insertUserSchema } from '@schema';
|
|
137
|
+
|
|
138
|
+
export const POST = defineHandler.withValidator({
|
|
139
|
+
body: insertUserSchema,
|
|
140
|
+
})(async (c, { body }) => {
|
|
141
|
+
const [created] = await db.insert(users).values(body).returning();
|
|
142
|
+
return created;
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
See [Database: Schema-Derived Validators](./database.md#schema-derived-validators) for how to set up `createInsertSchema` with column refinements.
|
|
147
|
+
|
|
148
|
+
### Manual validators
|
|
149
|
+
|
|
150
|
+
For endpoints that don't map to a database table, you can write validators by hand using any [Standard Schema](https://standardschema.dev/)-compatible library (Valibot, Zod, ArkType, etc.):
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
154
|
+
import * as v from 'valibot';
|
|
155
|
+
|
|
156
|
+
export const POST = defineHandler.withValidator({
|
|
157
|
+
body: v.object({
|
|
158
|
+
query: v.pipe(v.string(), v.minLength(1)),
|
|
159
|
+
limit: v.optional(v.pipe(v.number(), v.maxValue(100)), 10),
|
|
160
|
+
}),
|
|
161
|
+
})(async (c, { body }) => {
|
|
162
|
+
// body is typed as { query: string; limit: number }
|
|
163
|
+
return search(body.query, body.limit);
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Validation errors
|
|
168
|
+
|
|
169
|
+
When validation fails, a `400` response is returned with structured error details:
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
{
|
|
173
|
+
"error": "Validation failed",
|
|
174
|
+
"issues": [
|
|
175
|
+
{
|
|
176
|
+
"slot": "body",
|
|
177
|
+
"issues": [{ "message": "Invalid email", "path": "email" }]
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Install your chosen validator library; no separate Standard Schema dependency is needed.
|
|
184
|
+
|
|
185
|
+
Validator schemas also power the [typed fetch client](./typed-fetch.md), so `body`, `query`, and `params` types are enforced at the call site.
|
|
186
|
+
|
|
187
|
+
## Middleware
|
|
188
|
+
|
|
189
|
+
bwf uses Hono middleware. `defineMiddleware()` adds types to the usual `(c, next)` function, and `defineHandler()` also accepts Hono middleware directly.
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { defineMiddleware } from '@builtbyfriends/bwf';
|
|
193
|
+
|
|
194
|
+
export const addServerTiming = defineMiddleware(async (c, next) => {
|
|
195
|
+
const start = performance.now();
|
|
196
|
+
await next();
|
|
197
|
+
c.header('Server-Timing', `app;dur=${Math.round(performance.now() - start)}`);
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Any `hono/*` built-in middleware, response helpers, or third-party Hono ecosystem packages can be used in bwf apps. If you want to import from `hono/*` in your app, make sure to install `hono` in your app first:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm install hono
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
import { cors } from 'hono/cors';
|
|
209
|
+
|
|
210
|
+
const allowDashboard = cors({ origin: 'https://app.example.com' });
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
You can apply middleware globally or per-route.
|
|
214
|
+
|
|
215
|
+
### Global middleware
|
|
216
|
+
|
|
217
|
+
Global middleware runs on every request. Place files in `middleware/` and use numeric prefixes for ordering:
|
|
218
|
+
|
|
219
|
+
- `middleware/01.logger.ts`
|
|
220
|
+
- `middleware/02.auth.ts`
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import { defineMiddleware } from '@builtbyfriends/bwf';
|
|
224
|
+
|
|
225
|
+
export default defineMiddleware(async (c, next) => {
|
|
226
|
+
console.log(c.req.method, c.req.path);
|
|
227
|
+
await next();
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Use `basicAuth()` for a temporary site gate. bwf's reserved `/__nosam` endpoints remain accessible for deployment and development tooling. Read credentials through callbacks:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
// env.ts
|
|
235
|
+
import { defineEnv, string } from '@builtbyfriends/bwf/env';
|
|
236
|
+
|
|
237
|
+
export default defineEnv({
|
|
238
|
+
BASIC_AUTH_USERNAME: string(),
|
|
239
|
+
BASIC_AUTH_PASSWORD: string(),
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
// middleware/01.basic-auth.ts
|
|
245
|
+
import { basicAuth } from '@builtbyfriends/bwf';
|
|
246
|
+
import { env } from '@builtbyfriends/bwf/env';
|
|
247
|
+
|
|
248
|
+
export default basicAuth({
|
|
249
|
+
username: () => env.BASIC_AUTH_USERNAME,
|
|
250
|
+
password: () => env.BASIC_AUTH_PASSWORD,
|
|
251
|
+
realm: 'Preview',
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Set `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` as local environment variables for development and production secrets before deploy.
|
|
256
|
+
|
|
257
|
+
For app-specific bypasses such as health checks or public webhooks, compose that logic in your own middleware before calling `basicAuth()`.
|
|
258
|
+
|
|
259
|
+
Use `c.set()` to share data with downstream handlers. Augment `CloudContextVariables` for typed access with `c.get()`. See [Context variables](./type-safety.md#context-variables).
|
|
260
|
+
|
|
261
|
+
### Per-route middleware
|
|
262
|
+
|
|
263
|
+
Pass middleware to `defineHandler` before the final route handler:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
defineHandler(middleware1, middleware2, handler);
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Middleware runs in order. Each can short-circuit (return a response without calling `next()`) or post-process (modify the response after `await next()`). Both `defineMiddleware`-wrapped functions and raw Hono `MiddlewareHandler` functions are accepted.
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
273
|
+
// routes/api/stats.ts
|
|
274
|
+
import { cors } from 'hono/cors';
|
|
275
|
+
|
|
276
|
+
export const GET = defineHandler(cors({ origin: 'https://app.example.com' }), (c) => ({
|
|
277
|
+
stats: '...',
|
|
278
|
+
}));
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Up to 5 middleware can be passed before the handler, with full type inference for each position.
|
|
282
|
+
|
|
283
|
+
See the [Hono integration guide](../integrations/hono.md) for more examples.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Stream events from a route handler to the browser. bwf formats the messages, sends keepalives, and closes the stream.'
|
|
3
|
+
outline: deep
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Server-Sent Events
|
|
7
|
+
|
|
8
|
+
Use `@builtbyfriends/bwf/sse` to stream events from a route handler to the browser. bwf formats messages, sends keepalives, and closes the stream when the request ends.
|
|
9
|
+
|
|
10
|
+
SSE is a good fit for AI tokens, progress updates, or logs produced by one request. If other requests need to publish to connected clients, see [Live Event Streams](./live.md). Store events yourself if clients need to replay them.
|
|
11
|
+
|
|
12
|
+
## Server streams
|
|
13
|
+
|
|
14
|
+
Return `eventStream()` from a route handler:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// routes/api/events.ts
|
|
18
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
19
|
+
import { eventStream } from '@builtbyfriends/bwf/sse';
|
|
20
|
+
|
|
21
|
+
export const GET = defineHandler((c) => {
|
|
22
|
+
return eventStream(
|
|
23
|
+
async (stream) => {
|
|
24
|
+
await stream.comment('connected');
|
|
25
|
+
await stream.send({
|
|
26
|
+
event: 'ready',
|
|
27
|
+
data: { now: Date.now() },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const timer = setInterval(() => {
|
|
31
|
+
void stream.send({ event: 'tick', data: { now: Date.now() } }).catch(() => stream.close());
|
|
32
|
+
}, 1000);
|
|
33
|
+
|
|
34
|
+
await stream.closed;
|
|
35
|
+
clearInterval(timer);
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
signal: c.req.raw.signal,
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`eventStream()` returns a `Response` immediately with these default headers:
|
|
45
|
+
|
|
46
|
+
```http
|
|
47
|
+
Content-Type: text/event-stream; charset=utf-8
|
|
48
|
+
Cache-Control: no-cache, no-transform
|
|
49
|
+
X-Accel-Buffering: no
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
When the `start` callback returns, the stream closes. Long-lived streams should wait on `stream.closed`, a producer promise, or an application cancellation signal before returning.
|
|
53
|
+
|
|
54
|
+
## Sending events
|
|
55
|
+
|
|
56
|
+
Use `send()` for SSE messages and `comment()` for comments:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
await stream.send({
|
|
60
|
+
id: 'evt_1',
|
|
61
|
+
event: 'post.update',
|
|
62
|
+
retry: 1000,
|
|
63
|
+
data: { id: 'post_123', likes: 10 },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await stream.comment('still connected');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`data` accepts strings or JSON-serializable values. SSE is text-only.
|
|
70
|
+
|
|
71
|
+
Writing to a closed stream throws `SseStreamClosedError`.
|
|
72
|
+
|
|
73
|
+
Use `formatSseText()` to format a payload you have already serialized:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { formatSseText } from '@builtbyfriends/bwf/sse';
|
|
77
|
+
|
|
78
|
+
const frame = formatSseText({
|
|
79
|
+
event: 'post.update',
|
|
80
|
+
data: JSON.stringify({ id: 'post_123', likes: 10 }),
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Keepalives
|
|
85
|
+
|
|
86
|
+
Keepalives are enabled by default every 15 seconds:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
return eventStream(start);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Disable them or customize the interval and comment text:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
return eventStream(start, { keepAlive: false });
|
|
96
|
+
|
|
97
|
+
return eventStream(start, {
|
|
98
|
+
keepAlive: { intervalMs: 5000, comment: 'ping' },
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Last Event ID
|
|
103
|
+
|
|
104
|
+
Browsers send `Last-Event-ID` when reconnecting after an event with an `id` field. Use `getLastEventId()` to resume from your own storage:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { getLastEventId } from '@builtbyfriends/bwf/sse';
|
|
108
|
+
|
|
109
|
+
export const GET = defineHandler((c) => {
|
|
110
|
+
const lastId = getLastEventId(c.req.raw);
|
|
111
|
+
return eventStream(async (stream) => {
|
|
112
|
+
await stream.send({ id: nextId(lastId), data: await loadNextItem(lastId) });
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Client
|
|
118
|
+
|
|
119
|
+
Use `connectEventStream()` from the browser-only `@builtbyfriends/bwf/sse/client` subpath:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { connectEventStream } from '@builtbyfriends/bwf/sse/client';
|
|
123
|
+
|
|
124
|
+
const stream = connectEventStream<{
|
|
125
|
+
ready: { now: number };
|
|
126
|
+
tick: { now: number };
|
|
127
|
+
}>('/api/events', {
|
|
128
|
+
withCredentials: true,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const offReady = stream.on('ready', (event) => {
|
|
132
|
+
console.log(event.data.now);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
stream.on('tick', (event) => {
|
|
136
|
+
console.log(event.data.now);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
offReady();
|
|
140
|
+
stream.close();
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The client wraps native `EventSource`. It supports cookie credentials and typed event handlers, but it does not support request bodies or arbitrary headers. Use cookie auth, signed URLs, or a fetch-based streaming route when you need custom headers.
|
|
144
|
+
|
|
145
|
+
With [`routing.typedRoutes`](../reference/config.md#routing-typedroutes), TypeScript checks the URL against your routes, such as `` `/api/jobs/${id}` ``. External `http://` and `https://` URLs also work. For a URL you validate at runtime, use `as RouteUrl` from `@builtbyfriends/bwf/routes` to skip the type check.
|
|
146
|
+
|
|
147
|
+
JSON parsing is the default. Set `parse: 'text'` or pass a custom parser for non-JSON payloads:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
const logs = connectEventStream('/api/logs', { parse: 'text' });
|
|
151
|
+
|
|
152
|
+
logs.on('line', (event) => {
|
|
153
|
+
console.log(event.data);
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Auth
|
|
158
|
+
|
|
159
|
+
SSE routes are ordinary route handlers, so use the same auth checks you use for JSON routes:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { requireAuth } from '@builtbyfriends/bwf/auth';
|
|
163
|
+
|
|
164
|
+
export const GET = defineHandler(async (c) => {
|
|
165
|
+
const user = await requireAuth(c);
|
|
166
|
+
|
|
167
|
+
return eventStream(async (stream) => {
|
|
168
|
+
await stream.send({ event: 'ready', data: { userId: user.id } });
|
|
169
|
+
await stream.closed;
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
For shared topics and subscriptions, use [Live Event Streams](./live.md). For two-way communication, use [WebSockets](./websockets.md).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Store files in Cloudflare R2, and upload, download, and read metadata through bwf/storage.'
|
|
3
|
+
outline: deep
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Object Storage
|
|
7
|
+
|
|
8
|
+
Store files in [Cloudflare R2](https://developers.cloudflare.com/r2/) with `storage` from `@builtbyfriends/bwf/storage`. It gives you the typed R2 API for uploads, downloads, and metadata.
|
|
9
|
+
|
|
10
|
+
## Basic Operations
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { storage } from '@builtbyfriends/bwf/storage';
|
|
14
|
+
|
|
15
|
+
// Upload
|
|
16
|
+
await storage.put('uploads/photo.jpg', file, {
|
|
17
|
+
httpMetadata: { contentType: 'image/jpeg' },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Download
|
|
21
|
+
const object = await storage.get('uploads/photo.jpg');
|
|
22
|
+
if (object) {
|
|
23
|
+
const data = await object.arrayBuffer();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Delete
|
|
27
|
+
await storage.delete('uploads/photo.jpg');
|
|
28
|
+
|
|
29
|
+
// List
|
|
30
|
+
const listed = await storage.list({ prefix: 'uploads/' });
|
|
31
|
+
for (const obj of listed.objects) {
|
|
32
|
+
console.log(obj.key, obj.size);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Head (metadata only)
|
|
36
|
+
const head = await storage.head('uploads/photo.jpg');
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`storage` supports the full [R2Bucket API](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/).
|
|
40
|
+
|
|
41
|
+
## Serving Files
|
|
42
|
+
|
|
43
|
+
A common pattern is serving uploaded files from an API route:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// routes/files/[key].ts
|
|
47
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
48
|
+
import { storage } from '@builtbyfriends/bwf/storage';
|
|
49
|
+
|
|
50
|
+
export const GET = defineHandler(async (c) => {
|
|
51
|
+
const object = await storage.get(`uploads/${c.req.param('key')}`);
|
|
52
|
+
|
|
53
|
+
if (!object) {
|
|
54
|
+
return c.notFound();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const headers = new Headers();
|
|
58
|
+
object.writeHttpMetadata(headers);
|
|
59
|
+
headers.set('etag', object.httpEtag);
|
|
60
|
+
// Don't let an uploaded HTML or SVG file run as a page on your site.
|
|
61
|
+
headers.set('X-Content-Type-Options', 'nosniff');
|
|
62
|
+
headers.set('Content-Disposition', 'attachment');
|
|
63
|
+
|
|
64
|
+
return new Response(object.body, { headers });
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Files your users upload can contain HTML or scripts. Store them under keys your server picks, and serve them with `nosniff` and `Content-Disposition: attachment`. `<img>` and `<video>` tags still display them; opening the URL directly downloads the file.
|
|
69
|
+
|
|
70
|
+
## Custom bindings
|
|
71
|
+
|
|
72
|
+
To use another R2 bucket, add it to `cloudflare.r2_buckets` in `bwf.config.ts`, for example `{ binding: 'MY_BUCKET', bucket_name: 'uploads' }`. Run `bwf prepare`, then pass the typed binding to `createStorage()`:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { defineHandler } from '@builtbyfriends/bwf';
|
|
76
|
+
import { createStorage } from '@builtbyfriends/bwf/storage';
|
|
77
|
+
|
|
78
|
+
export const GET = defineHandler((c) => {
|
|
79
|
+
const storage = createStorage(c.env.MY_BUCKET);
|
|
80
|
+
return storage.list();
|
|
81
|
+
});
|
|
82
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Run tests with Vitest and Vite+, mock Cloudflare bindings, and test email with the built-in harnesses.'
|
|
3
|
+
outline: deep
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Testing
|
|
7
|
+
|
|
8
|
+
bwf apps use [Vitest](https://vitest.dev/). With Vite+, run your tests with:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
vp test
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Import `it`, `expect`, and other test APIs from `vite-plus/test`. If you chose Vite instead of Vite+, install `vitest` as a dev dependency and use `vitest` for both the imports and command.
|
|
15
|
+
|
|
16
|
+
Vitest uses your `vite.config.ts`. Imports such as `bwf/*` and `@schema` work without extra test configuration.
|
|
17
|
+
|
|
18
|
+
Put tests in `tests/` or beside the code they test in `src/`. Keep them out of [convention directories](../reference/structure.md) such as `routes/`, where bwf would treat them as app routes.
|
|
19
|
+
|
|
20
|
+
## Bindings {#bindings}
|
|
21
|
+
|
|
22
|
+
Tests run in Node.js without starting a Worker or applying local migrations. To test code that uses D1, KV, R2, or another binding, mock the module with [`vi.mock()`](https://vitest.dev/api/vi#vi-mock).
|
|
23
|
+
|
|
24
|
+
For example, this function counts visits in KV:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// src/visits.ts
|
|
28
|
+
import { kv } from '@builtbyfriends/bwf/kv';
|
|
29
|
+
|
|
30
|
+
export async function countVisit(): Promise<number> {
|
|
31
|
+
const visits = ((await kv.get<number>('visits')) ?? 0) + 1;
|
|
32
|
+
await kv.put('visits', visits);
|
|
33
|
+
return visits;
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Replace KV with an in-memory map in the test:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// src/visits.test.ts
|
|
41
|
+
import { expect, it, vi } from 'vite-plus/test';
|
|
42
|
+
import { countVisit } from './visits';
|
|
43
|
+
|
|
44
|
+
vi.mock('@builtbyfriends/bwf/kv', () => {
|
|
45
|
+
const values = new Map<string, unknown>();
|
|
46
|
+
return {
|
|
47
|
+
kv: {
|
|
48
|
+
get: async (key: string) => values.get(key) ?? null,
|
|
49
|
+
put: async (key: string, value: unknown) => {
|
|
50
|
+
values.set(key, value);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('counts visits', async () => {
|
|
57
|
+
await countVisit();
|
|
58
|
+
expect(await countVisit()).toBe(2);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Email {#email}
|
|
63
|
+
|
|
64
|
+
`@builtbyfriends/bwf/email/testing` captures sent and received email in tests. See [Testing](./email/sending.md#testing) in Sending Email and [Testing inbound handlers](./email/receiving.md#testing-inbound-handlers) in Receiving Email.
|