spacefn-docs 0.0.0-stage → 0.11.1
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/LICENSE +200 -0
- package/README.md +15 -2
- package/assets/reader.css +1131 -0
- package/assets/reader.js +324 -0
- package/content/1-getting-started.md +107 -0
- package/content/2-conventions.md +138 -0
- package/content/3-best-practices.md +68 -0
- package/content/4-folders/1-app/1-entry.md +48 -0
- package/content/4-folders/1-app/2-routes.md +92 -0
- package/content/4-folders/1-app/3-db.md +81 -0
- package/content/4-folders/1-app/4-queues.md +46 -0
- package/content/4-folders/1-app/5-crons.md +30 -0
- package/content/4-folders/1-app/6-assets.md +53 -0
- package/content/4-folders/1-app/7-durable-objects.md +60 -0
- package/content/4-folders/1-app/8-workflows.md +46 -0
- package/content/4-folders/1-app/index.md +43 -0
- package/content/4-folders/2-modules.md +71 -0
- package/content/4-folders/3-lib.md +60 -0
- package/content/4-folders/4-public.md +24 -0
- package/content/4-folders/5-docs.md +23 -0
- package/content/4-folders/6-configs.md +57 -0
- package/content/4-folders/7-space.md +34 -0
- package/content/4-folders/8-env.md +35 -0
- package/content/4-folders/9-package-json.md +37 -0
- package/content/4-folders/index.md +50 -0
- package/content/5-deployment/1-cloudflare.md +70 -0
- package/content/5-deployment/2-bun.md +68 -0
- package/content/5-deployment/3-infrastructure.md +67 -0
- package/content/5-deployment/4-ci-cd.md +179 -0
- package/content/5-deployment/index.md +48 -0
- package/content/6-guides/1-entry.md +113 -0
- package/content/6-guides/2-routes.md +162 -0
- package/content/6-guides/3-pages.md +148 -0
- package/content/6-guides/4-frontend.md +232 -0
- package/content/6-guides/5-database.md +178 -0
- package/content/6-guides/6-services.md +125 -0
- package/content/6-guides/7-jobs.md +61 -0
- package/content/6-guides/8-auth.md +111 -0
- package/content/6-guides/9-testing.md +70 -0
- package/content/6-guides/index.md +21 -0
- package/content/7-reference/1-config.md +67 -0
- package/content/7-reference/2-cli.md +45 -0
- package/content/7-reference/3-writing-docs.md +206 -0
- package/content/7-reference/index.md +15 -0
- package/content/index.md +49 -0
- package/content/logo.svg +12 -0
- package/dist/index.d.mts +72 -0
- package/dist/index.mjs +713 -0
- package/examples/README.md +18 -0
- package/examples/datastar/.env.example +2 -0
- package/examples/datastar/README.md +17 -0
- package/examples/datastar/app/assets/main.ts +4 -0
- package/examples/datastar/app/assets/site.css +3 -0
- package/examples/datastar/app/db/main/config.json +5 -0
- package/examples/datastar/app/db/main/migrations/0001_votes.sql +8 -0
- package/examples/datastar/app/db/main/queries/add-vote.sql +3 -0
- package/examples/datastar/app/db/main/queries/tally.sql +1 -0
- package/examples/datastar/app/entry.ts +28 -0
- package/examples/datastar/app/routes/_middleware.ts +4 -0
- package/examples/datastar/app/routes/health.ts +7 -0
- package/examples/datastar/app/routes/index.ts +43 -0
- package/examples/datastar/configs/env.ts +6 -0
- package/examples/datastar/configs/infra.ts +88 -0
- package/examples/datastar/configs/tsconfig.json +15 -0
- package/examples/datastar/configs/vite.ts +4 -0
- package/examples/datastar/configs/vitest.ts +9 -0
- package/examples/datastar/lib/types/rocket.d.ts +30 -0
- package/examples/datastar/lib/ui/base.css +17 -0
- package/examples/datastar/lib/ui/layout.ts +27 -0
- package/examples/datastar/modules/poll/client/poll-meter.ts +39 -0
- package/examples/datastar/modules/poll/poll.css +13 -0
- package/examples/datastar/modules/poll/poll.test.ts +48 -0
- package/examples/datastar/modules/poll/poll.ts +62 -0
- package/examples/datastar/modules/poll/views.ts +52 -0
- package/examples/datastar/package.json +33 -0
- package/examples/datastar/tsconfig.json +4 -0
- package/examples/lightningcss/.env.example +1 -0
- package/examples/lightningcss/README.md +15 -0
- package/examples/lightningcss/app/assets/site.css +3 -0
- package/examples/lightningcss/app/entry.ts +28 -0
- package/examples/lightningcss/app/routes/_middleware.ts +4 -0
- package/examples/lightningcss/app/routes/health.ts +7 -0
- package/examples/lightningcss/app/routes/index.ts +12 -0
- package/examples/lightningcss/configs/Dockerfile +26 -0
- package/examples/lightningcss/configs/Dockerfile.dockerignore +9 -0
- package/examples/lightningcss/configs/env.ts +4 -0
- package/examples/lightningcss/configs/infra.ts +55 -0
- package/examples/lightningcss/configs/tsconfig.json +15 -0
- package/examples/lightningcss/configs/vite.ts +19 -0
- package/examples/lightningcss/configs/vitest.ts +9 -0
- package/examples/lightningcss/lib/ui/layout.ts +17 -0
- package/examples/lightningcss/lib/ui/tokens.css +23 -0
- package/examples/lightningcss/modules/releases/releases.css +20 -0
- package/examples/lightningcss/modules/releases/releases.test.ts +18 -0
- package/examples/lightningcss/modules/releases/releases.ts +21 -0
- package/examples/lightningcss/modules/releases/views.ts +25 -0
- package/examples/lightningcss/package.json +33 -0
- package/examples/lightningcss/tsconfig.json +4 -0
- package/examples/mini-shopify/.env.example +6 -0
- package/examples/mini-shopify/README.md +19 -0
- package/examples/mini-shopify/app/assets/site.css +2 -0
- package/examples/mini-shopify/app/db/platform/config.json +5 -0
- package/examples/mini-shopify/app/db/platform/migrations/0001_shops.sql +10 -0
- package/examples/mini-shopify/app/db/platform/queries/add-shop.sql +4 -0
- package/examples/mini-shopify/app/db/platform/queries/find-shop.sql +3 -0
- package/examples/mini-shopify/app/db/platform/queries/list-shops.sql +1 -0
- package/examples/mini-shopify/app/db/shop/config.json +6 -0
- package/examples/mini-shopify/app/db/shop/migrations/0001_products.sql +11 -0
- package/examples/mini-shopify/app/db/shop/queries/add-product.sql +4 -0
- package/examples/mini-shopify/app/db/shop/queries/list-products.sql +1 -0
- package/examples/mini-shopify/app/db/shop/queries/sell-product.sql +2 -0
- package/examples/mini-shopify/app/entry.ts +25 -0
- package/examples/mini-shopify/app/routes/_middleware.ts +4 -0
- package/examples/mini-shopify/app/routes/health.ts +7 -0
- package/examples/mini-shopify/app/routes/index.ts +26 -0
- package/examples/mini-shopify/app/routes/s/[shop]/_middleware.ts +6 -0
- package/examples/mini-shopify/app/routes/s/[shop]/index.ts +32 -0
- package/examples/mini-shopify/configs/Dockerfile +26 -0
- package/examples/mini-shopify/configs/Dockerfile.dockerignore +9 -0
- package/examples/mini-shopify/configs/env.ts +14 -0
- package/examples/mini-shopify/configs/infra.ts +55 -0
- package/examples/mini-shopify/configs/tsconfig.json +15 -0
- package/examples/mini-shopify/configs/vite.ts +4 -0
- package/examples/mini-shopify/configs/vitest.ts +9 -0
- package/examples/mini-shopify/lib/ui/base.css +19 -0
- package/examples/mini-shopify/lib/ui/layout.ts +17 -0
- package/examples/mini-shopify/modules/catalog/catalog.ts +31 -0
- package/examples/mini-shopify/modules/catalog/views.ts +39 -0
- package/examples/mini-shopify/modules/shops/host.test.ts +38 -0
- package/examples/mini-shopify/modules/shops/host.ts +73 -0
- package/examples/mini-shopify/modules/shops/shops.test.ts +63 -0
- package/examples/mini-shopify/modules/shops/shops.ts +64 -0
- package/examples/mini-shopify/modules/shops/views.ts +28 -0
- package/examples/mini-shopify/package.json +35 -0
- package/examples/mini-shopify/tsconfig.json +4 -0
- package/examples/react/.env.example +2 -0
- package/examples/react/README.md +18 -0
- package/examples/react/app/assets/site.css +3 -0
- package/examples/react/app/entry.ts +28 -0
- package/examples/react/app/routes/_middleware.ts +4 -0
- package/examples/react/app/routes/about.ts +10 -0
- package/examples/react/app/routes/health.ts +7 -0
- package/examples/react/app/routes/index.ts +12 -0
- package/examples/react/configs/Dockerfile +26 -0
- package/examples/react/configs/Dockerfile.dockerignore +9 -0
- package/examples/react/configs/env.ts +6 -0
- package/examples/react/configs/infra.ts +55 -0
- package/examples/react/configs/tsconfig.json +16 -0
- package/examples/react/configs/vite.ts +7 -0
- package/examples/react/configs/vitest.ts +9 -0
- package/examples/react/lib/ui/base.css +12 -0
- package/examples/react/lib/ui/layout.ts +18 -0
- package/examples/react/modules/about/views.ts +8 -0
- package/examples/react/modules/shop/products.ts +18 -0
- package/examples/react/modules/shop/shop.css +13 -0
- package/examples/react/modules/shop/shop.test.ts +28 -0
- package/examples/react/modules/shop/shop.ts +13 -0
- package/examples/react/modules/shop/ui/Cart.island.tsx +31 -0
- package/examples/react/modules/shop/views.ts +16 -0
- package/examples/react/package.json +38 -0
- package/examples/react/tsconfig.json +4 -0
- package/examples/services-bun/README.md +10 -0
- package/examples/services-bun/app/assets/main.ts +4 -0
- package/examples/services-bun/app/assets/style.css +1 -0
- package/examples/services-bun/app/crons/nightly.ts +5 -0
- package/examples/services-bun/app/entry.ts +9 -0
- package/examples/services-bun/app/queues/jobs.ts +5 -0
- package/examples/services-bun/app/routes/index.ts +10 -0
- package/examples/services-bun/app/routes/runtime.ts +5 -0
- package/examples/services-bun/app/routes/send.ts +8 -0
- package/examples/services-bun/app/routes/version.ts +5 -0
- package/examples/services-bun/configs/Dockerfile +10 -0
- package/examples/services-bun/configs/Dockerfile.dockerignore +4 -0
- package/examples/services-bun/configs/infra.ts +28 -0
- package/examples/services-bun/configs/tsconfig.json +15 -0
- package/examples/services-bun/configs/vite.ts +4 -0
- package/examples/services-bun/lib/ui/base.css +3 -0
- package/examples/services-bun/lib/ui/layout.ts +13 -0
- package/examples/services-bun/modules/status/client/ready.ts +4 -0
- package/examples/services-bun/modules/status/status.ts +20 -0
- package/examples/services-bun/modules/status/views.ts +4 -0
- package/examples/services-bun/package.json +30 -0
- package/examples/services-bun/public/robots.txt +1 -0
- package/examples/services-bun/tsconfig.json +4 -0
- package/examples/services-cloudflare/README.md +9 -0
- package/examples/services-cloudflare/app/assets/main.ts +4 -0
- package/examples/services-cloudflare/app/crons/nightly.ts +5 -0
- package/examples/services-cloudflare/app/db/main/config.json +4 -0
- package/examples/services-cloudflare/app/db/main/migrations/0001_notes.sql +2 -0
- package/examples/services-cloudflare/app/db/main/queries/add-note.sql +1 -0
- package/examples/services-cloudflare/app/db/main/queries/count-notes.sql +3 -0
- package/examples/services-cloudflare/app/entry.ts +10 -0
- package/examples/services-cloudflare/app/queues/jobs.ts +5 -0
- package/examples/services-cloudflare/app/routes/files.ts +5 -0
- package/examples/services-cloudflare/app/routes/index.ts +10 -0
- package/examples/services-cloudflare/app/routes/limited.ts +7 -0
- package/examples/services-cloudflare/app/routes/send.ts +8 -0
- package/examples/services-cloudflare/configs/env.ts +3 -0
- package/examples/services-cloudflare/configs/infra.ts +88 -0
- package/examples/services-cloudflare/configs/tsconfig.json +15 -0
- package/examples/services-cloudflare/configs/vite.ts +4 -0
- package/examples/services-cloudflare/lib/ui/layout.ts +12 -0
- package/examples/services-cloudflare/modules/files/files.ts +9 -0
- package/examples/services-cloudflare/modules/status/client/ready.ts +4 -0
- package/examples/services-cloudflare/modules/status/status.ts +27 -0
- package/examples/services-cloudflare/modules/status/views.ts +8 -0
- package/examples/services-cloudflare/package.json +30 -0
- package/examples/services-cloudflare/public/robots.txt +1 -0
- package/examples/services-cloudflare/tsconfig.json +4 -0
- package/examples/solid/.env.example +2 -0
- package/examples/solid/README.md +18 -0
- package/examples/solid/app/assets/site.css +3 -0
- package/examples/solid/app/entry.ts +28 -0
- package/examples/solid/app/routes/_middleware.ts +4 -0
- package/examples/solid/app/routes/about.ts +10 -0
- package/examples/solid/app/routes/health.ts +7 -0
- package/examples/solid/app/routes/index.ts +12 -0
- package/examples/solid/configs/Dockerfile +26 -0
- package/examples/solid/configs/Dockerfile.dockerignore +9 -0
- package/examples/solid/configs/env.ts +6 -0
- package/examples/solid/configs/infra.ts +55 -0
- package/examples/solid/configs/tsconfig.json +17 -0
- package/examples/solid/configs/vite.ts +7 -0
- package/examples/solid/configs/vitest.ts +12 -0
- package/examples/solid/lib/ui/base.css +12 -0
- package/examples/solid/lib/ui/layout.ts +18 -0
- package/examples/solid/modules/about/views.ts +8 -0
- package/examples/solid/modules/shop/products.ts +18 -0
- package/examples/solid/modules/shop/shop.css +13 -0
- package/examples/solid/modules/shop/shop.test.ts +28 -0
- package/examples/solid/modules/shop/shop.ts +13 -0
- package/examples/solid/modules/shop/ui/Cart.island.tsx +31 -0
- package/examples/solid/modules/shop/views.ts +16 -0
- package/examples/solid/package.json +35 -0
- package/examples/solid/tsconfig.json +4 -0
- package/examples/starter-bun/.env.example +2 -0
- package/examples/starter-bun/AGENTS.md +9 -0
- package/examples/starter-bun/README.md +47 -0
- package/examples/starter-bun/app/assets/site.css +3 -0
- package/examples/starter-bun/app/db/main/config.json +5 -0
- package/examples/starter-bun/app/db/main/migrations/0001_todos.sql +9 -0
- package/examples/starter-bun/app/db/main/queries/add-todo.sql +2 -0
- package/examples/starter-bun/app/db/main/queries/list-todos.sql +2 -0
- package/examples/starter-bun/app/db/main/queries/toggle-todo.sql +2 -0
- package/examples/starter-bun/app/entry.ts +28 -0
- package/examples/starter-bun/app/routes/_middleware.ts +4 -0
- package/examples/starter-bun/app/routes/health.ts +7 -0
- package/examples/starter-bun/app/routes/index.ts +44 -0
- package/examples/starter-bun/configs/Dockerfile +26 -0
- package/examples/starter-bun/configs/Dockerfile.dockerignore +9 -0
- package/examples/starter-bun/configs/env.ts +6 -0
- package/examples/starter-bun/configs/infra.ts +55 -0
- package/examples/starter-bun/configs/tsconfig.json +15 -0
- package/examples/starter-bun/configs/vite.ts +4 -0
- package/examples/starter-bun/configs/vitest.ts +9 -0
- package/examples/starter-bun/docs/index.md +5 -0
- package/examples/starter-bun/lib/ui/base.css +17 -0
- package/examples/starter-bun/lib/ui/layout.ts +22 -0
- package/examples/starter-bun/modules/todos/todos.css +16 -0
- package/examples/starter-bun/modules/todos/todos.test.ts +33 -0
- package/examples/starter-bun/modules/todos/todos.ts +31 -0
- package/examples/starter-bun/modules/todos/views.ts +38 -0
- package/examples/starter-bun/package.json +32 -0
- package/examples/starter-bun/public/favicon.svg +1 -0
- package/examples/starter-bun/tsconfig.json +4 -0
- package/examples/starter-cloudflare/.env.example +2 -0
- package/examples/starter-cloudflare/AGENTS.md +9 -0
- package/examples/starter-cloudflare/README.md +47 -0
- package/examples/starter-cloudflare/app/assets/site.css +3 -0
- package/examples/starter-cloudflare/app/db/main/config.json +5 -0
- package/examples/starter-cloudflare/app/db/main/migrations/0001_todos.sql +9 -0
- package/examples/starter-cloudflare/app/db/main/queries/add-todo.sql +2 -0
- package/examples/starter-cloudflare/app/db/main/queries/list-todos.sql +2 -0
- package/examples/starter-cloudflare/app/db/main/queries/toggle-todo.sql +2 -0
- package/examples/starter-cloudflare/app/entry.ts +28 -0
- package/examples/starter-cloudflare/app/routes/_middleware.ts +4 -0
- package/examples/starter-cloudflare/app/routes/health.ts +7 -0
- package/examples/starter-cloudflare/app/routes/index.ts +44 -0
- package/examples/starter-cloudflare/configs/env.ts +6 -0
- package/examples/starter-cloudflare/configs/infra.ts +88 -0
- package/examples/starter-cloudflare/configs/tsconfig.json +15 -0
- package/examples/starter-cloudflare/configs/vite.ts +4 -0
- package/examples/starter-cloudflare/configs/vitest.ts +9 -0
- package/examples/starter-cloudflare/docs/index.md +5 -0
- package/examples/starter-cloudflare/lib/ui/base.css +17 -0
- package/examples/starter-cloudflare/lib/ui/layout.ts +22 -0
- package/examples/starter-cloudflare/modules/todos/todos.css +16 -0
- package/examples/starter-cloudflare/modules/todos/todos.test.ts +33 -0
- package/examples/starter-cloudflare/modules/todos/todos.ts +31 -0
- package/examples/starter-cloudflare/modules/todos/views.ts +38 -0
- package/examples/starter-cloudflare/package.json +35 -0
- package/examples/starter-cloudflare/public/favicon.svg +1 -0
- package/examples/starter-cloudflare/tsconfig.json +4 -0
- package/examples/svelte/.env.example +2 -0
- package/examples/svelte/README.md +18 -0
- package/examples/svelte/app/assets/site.css +3 -0
- package/examples/svelte/app/entry.ts +28 -0
- package/examples/svelte/app/routes/_middleware.ts +4 -0
- package/examples/svelte/app/routes/about.ts +10 -0
- package/examples/svelte/app/routes/health.ts +7 -0
- package/examples/svelte/app/routes/index.ts +12 -0
- package/examples/svelte/configs/env.ts +6 -0
- package/examples/svelte/configs/infra.ts +88 -0
- package/examples/svelte/configs/tsconfig.json +15 -0
- package/examples/svelte/configs/vite.ts +9 -0
- package/examples/svelte/configs/vitest.ts +9 -0
- package/examples/svelte/lib/types/svelte.d.ts +8 -0
- package/examples/svelte/lib/ui/base.css +12 -0
- package/examples/svelte/lib/ui/layout.ts +18 -0
- package/examples/svelte/modules/about/views.ts +8 -0
- package/examples/svelte/modules/shop/products.ts +18 -0
- package/examples/svelte/modules/shop/shop.css +13 -0
- package/examples/svelte/modules/shop/shop.test.ts +28 -0
- package/examples/svelte/modules/shop/shop.ts +13 -0
- package/examples/svelte/modules/shop/ui/Cart.island.svelte +23 -0
- package/examples/svelte/modules/shop/views.ts +16 -0
- package/examples/svelte/package.json +35 -0
- package/examples/svelte/tsconfig.json +4 -0
- package/examples/tailwind/.env.example +2 -0
- package/examples/tailwind/README.md +16 -0
- package/examples/tailwind/app/assets/site.css +2 -0
- package/examples/tailwind/app/entry.ts +28 -0
- package/examples/tailwind/app/routes/_middleware.ts +4 -0
- package/examples/tailwind/app/routes/health.ts +7 -0
- package/examples/tailwind/app/routes/index.ts +30 -0
- package/examples/tailwind/configs/Dockerfile +26 -0
- package/examples/tailwind/configs/Dockerfile.dockerignore +9 -0
- package/examples/tailwind/configs/env.ts +6 -0
- package/examples/tailwind/configs/infra.ts +55 -0
- package/examples/tailwind/configs/tsconfig.json +15 -0
- package/examples/tailwind/configs/vite.ts +7 -0
- package/examples/tailwind/configs/vitest.ts +9 -0
- package/examples/tailwind/lib/ui/components.ts +21 -0
- package/examples/tailwind/lib/ui/layout.ts +21 -0
- package/examples/tailwind/lib/ui/theme.css +10 -0
- package/examples/tailwind/modules/team/team.test.ts +30 -0
- package/examples/tailwind/modules/team/team.ts +34 -0
- package/examples/tailwind/modules/team/views.ts +45 -0
- package/examples/tailwind/package.json +35 -0
- package/examples/tailwind/tsconfig.json +4 -0
- package/examples/vue/.env.example +2 -0
- package/examples/vue/README.md +18 -0
- package/examples/vue/app/assets/site.css +3 -0
- package/examples/vue/app/entry.ts +28 -0
- package/examples/vue/app/routes/_middleware.ts +4 -0
- package/examples/vue/app/routes/about.ts +10 -0
- package/examples/vue/app/routes/health.ts +7 -0
- package/examples/vue/app/routes/index.ts +12 -0
- package/examples/vue/configs/env.ts +6 -0
- package/examples/vue/configs/infra.ts +88 -0
- package/examples/vue/configs/tsconfig.json +15 -0
- package/examples/vue/configs/vite.ts +7 -0
- package/examples/vue/configs/vitest.ts +9 -0
- package/examples/vue/lib/types/vue.d.ts +8 -0
- package/examples/vue/lib/ui/base.css +12 -0
- package/examples/vue/lib/ui/layout.ts +18 -0
- package/examples/vue/modules/about/views.ts +8 -0
- package/examples/vue/modules/shop/products.ts +18 -0
- package/examples/vue/modules/shop/shop.css +13 -0
- package/examples/vue/modules/shop/shop.test.ts +28 -0
- package/examples/vue/modules/shop/shop.ts +13 -0
- package/examples/vue/modules/shop/ui/Cart.island.vue +27 -0
- package/examples/vue/modules/shop/views.ts +16 -0
- package/examples/vue/package.json +35 -0
- package/examples/vue/tsconfig.json +4 -0
- package/package.json +44 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "solid",
|
|
3
|
+
"private": true,
|
|
4
|
+
"description": "A Solid island on a server-rendered spacefn page: a client-only cart, loaded only on the page that uses it.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"imports": {
|
|
7
|
+
"#configs/*": "./configs/*",
|
|
8
|
+
"#lib/*": "./lib/*",
|
|
9
|
+
"#modules/*": "./modules/*",
|
|
10
|
+
"#space/*": "./.space/*"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "space gen",
|
|
14
|
+
"dev": "space dev",
|
|
15
|
+
"build": "space build",
|
|
16
|
+
"deploy": "space deploy",
|
|
17
|
+
"docs": "space docs",
|
|
18
|
+
"test": "vitest run --config configs/vitest.ts",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"effect": "4.1.4",
|
|
23
|
+
"solid-js": "1.9.18",
|
|
24
|
+
"spacefn": "^0.11.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@alchemy.run/docker": "2.0.0-beta.87",
|
|
28
|
+
"alchemy": "2.0.0-beta.87",
|
|
29
|
+
"spacefn-docs": "^0.11.1",
|
|
30
|
+
"typescript": "^7.0.2",
|
|
31
|
+
"vite": "8.3.8",
|
|
32
|
+
"vite-plugin-solid": "2.11.15",
|
|
33
|
+
"vitest": "5.1.1"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Notes for coding agents
|
|
2
|
+
|
|
3
|
+
This is a spacefn app, on Effect 4. spacefn's docs (`content/`) and example apps (`examples/`) for the installed version are in `node_modules/spacefn-docs/`: read them before guessing an API.
|
|
4
|
+
|
|
5
|
+
- `app/` only wires the runtime: its files connect code from `modules/` and `lib/` to routes, pages, jobs and the entry, with no logic or markup of their own.
|
|
6
|
+
- A feature's logic, views, client code and tests go in `modules/<feature>/`. Code shared by features (UI kit, design tokens, helpers) goes in `lib/`, which doesn't import `modules/`.
|
|
7
|
+
- `.space/` is generated: never edit it. After adding, removing or renaming a file in `app/`, run `npx space gen` (`npm run dev` does it on its own).
|
|
8
|
+
- `configs/env.ts` is imported by deploys, so it may import only `spacefn` and `effect`.
|
|
9
|
+
- Check your work with `npm run typecheck` and `npm test`; `npx space doctor` explains setup problems.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# spacefn app
|
|
2
|
+
|
|
3
|
+
A [spacefn](https://github.com/space-fn/spacefn) app: folders of convention files on [Effect](https://effect.website), served on Cloudflare Workers or Bun.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Command | What it does |
|
|
8
|
+
| ------------------ | ------------------------------------------------------------------------- |
|
|
9
|
+
| `npm run dev` | Runs the app locally, reloading on every change |
|
|
10
|
+
| `npm test` | Runs the tests |
|
|
11
|
+
| `npm run build` | Builds for production (Bun: `dist/`) |
|
|
12
|
+
| `npm run deploy` | Deploys (Cloudflare: your account; Bun: a Docker container), stage `prod` |
|
|
13
|
+
| `npm run docs` | Shows `docs/` and spacefn's docs in the browser |
|
|
14
|
+
| `npx space doctor` | Checks what dev and deploy need |
|
|
15
|
+
|
|
16
|
+
Local settings go in `.env` (copy `.env.example`). A deploy reads `.env.<stage>`, e.g. `.env.prod`, or the environment.
|
|
17
|
+
|
|
18
|
+
## Where things go
|
|
19
|
+
|
|
20
|
+
`app/` holds what spacefn reads, and each file there only connects code from `modules/` and `lib/`.
|
|
21
|
+
|
|
22
|
+
```txt
|
|
23
|
+
my-app/
|
|
24
|
+
├── app/
|
|
25
|
+
│ ├── entry.ts the app: its services, what wraps every request, onError
|
|
26
|
+
│ ├── routes/ pages and endpoints: index.ts is /, todos/[id].ts is /todos/:id
|
|
27
|
+
│ │ └── _middleware.ts wraps the requests to its folder
|
|
28
|
+
│ ├── db/
|
|
29
|
+
│ │ └── main/ config.json (driver, migrateOn), migrations/ and queries/ in SQL
|
|
30
|
+
│ ├── queues/ queue consumers, one per file
|
|
31
|
+
│ ├── crons/ scheduled jobs, one per file
|
|
32
|
+
│ └── assets/ browser entries, bundled by Vite; a page loads them with assets("name")
|
|
33
|
+
├── modules/
|
|
34
|
+
│ └── todos/ a feature: its logic, views, client code and tests
|
|
35
|
+
├── lib/
|
|
36
|
+
│ └── ui/ code features share: the layout and the base styles
|
|
37
|
+
├── public/ files served as they are at /
|
|
38
|
+
├── docs/ notes on this app, in Markdown: npm run docs shows them
|
|
39
|
+
├── configs/
|
|
40
|
+
│ ├── env.ts the variables the app reads
|
|
41
|
+
│ ├── vite.ts Vite, with spacefn's plugin and the target
|
|
42
|
+
│ ├── vitest.ts
|
|
43
|
+
│ └── tsconfig.json
|
|
44
|
+
└── .space/ generated by `space gen`; never edit it
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Import from the app root with `#modules/...`, `#lib/...` and `#configs/...`. `npm test` runs every `*.test.ts` in `app/`, `modules/` and `lib/`.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { app, databases, errorPage, staticFiles, telemetry } from "spacefn";
|
|
2
|
+
import { platform } from "spacefn/platform";
|
|
3
|
+
|
|
4
|
+
import Env from "#configs/env.ts";
|
|
5
|
+
import { manifest } from "#space/manifest.ts";
|
|
6
|
+
|
|
7
|
+
// The app: the file conventions (manifest) and what runs with them. It's yours to change;
|
|
8
|
+
// spacefn only provides the pieces. The same file runs on Cloudflare and on Bun.
|
|
9
|
+
export default app(manifest, {
|
|
10
|
+
// In order: each can use the ones before it, and routes, pages, queues and crons use them all.
|
|
11
|
+
services: [
|
|
12
|
+
// This target's Kv, Blob, Queue, Bus, RateLimiter, HttpClient and database connections.
|
|
13
|
+
platform(manifest),
|
|
14
|
+
// configs/env.ts, read from the environment.
|
|
15
|
+
Env.layer,
|
|
16
|
+
// app/db/*, migrated as each config.json says.
|
|
17
|
+
databases(manifest),
|
|
18
|
+
// Traces, logs and metrics over OTLP, once OTEL_EXPORTER_OTLP_ENDPOINT is set.
|
|
19
|
+
telemetry(manifest.name),
|
|
20
|
+
],
|
|
21
|
+
// Around every request, before app/routes/_middleware.ts. staticFiles() serves the client
|
|
22
|
+
// build on Bun; Cloudflare serves it as assets before the Worker runs.
|
|
23
|
+
before: [staticFiles()],
|
|
24
|
+
// Effect HttpRouter layers beside the file routes, e.g. an HttpApi.
|
|
25
|
+
routes: [],
|
|
26
|
+
// What a failed request answers: an HTML page for browsers, JSON for the rest.
|
|
27
|
+
onError: errorPage,
|
|
28
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { action, actionUrl, Datastar, page, redirect } from "spacefn";
|
|
3
|
+
|
|
4
|
+
import { layout } from "#lib/ui/layout.ts";
|
|
5
|
+
import * as Todos from "#modules/todos/todos.ts";
|
|
6
|
+
import { todoList, todosPage } from "#modules/todos/views.ts";
|
|
7
|
+
|
|
8
|
+
// The page at /. It only connects the todos module to the web: the logic and the markup are there.
|
|
9
|
+
|
|
10
|
+
const list = Todos.list.pipe(
|
|
11
|
+
Effect.map((todos) => todoList({ todos, toggle: actionUrl("toggle") })),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default page({
|
|
15
|
+
loader: Effect.all({ greeting: Todos.greeting, list }),
|
|
16
|
+
actions: {
|
|
17
|
+
// After a form post, send the browser back to the list.
|
|
18
|
+
add: action({
|
|
19
|
+
input: Todos.NewTodo,
|
|
20
|
+
handler: (todo) => Effect.as(Todos.add(todo), redirect("/")),
|
|
21
|
+
}),
|
|
22
|
+
toggle: action({
|
|
23
|
+
input: Todos.TodoRef,
|
|
24
|
+
handler: (todo) => Effect.as(Todos.toggle(todo), redirect("/")),
|
|
25
|
+
}),
|
|
26
|
+
// Datastar opens this when the page loads, and gets the list again after each change.
|
|
27
|
+
live: action({
|
|
28
|
+
method: "get",
|
|
29
|
+
input: Schema.Struct({}),
|
|
30
|
+
handler: () => Datastar.watch([Todos.TOPIC], list),
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
render: (ctx) =>
|
|
34
|
+
layout(
|
|
35
|
+
"Todos",
|
|
36
|
+
todosPage({
|
|
37
|
+
greeting: ctx.data.greeting,
|
|
38
|
+
list: ctx.data.list,
|
|
39
|
+
add: ctx.actions.add.url,
|
|
40
|
+
live: ctx.actions.live.url,
|
|
41
|
+
untitled: ctx.actions.add.ok === false,
|
|
42
|
+
}),
|
|
43
|
+
),
|
|
44
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# The app's image on Bun, built from its source when `space deploy` runs configs/infra.ts.
|
|
2
|
+
# configs/Dockerfile.dockerignore keeps local files out of it.
|
|
3
|
+
ARG BUN_VERSION=1.4.4
|
|
4
|
+
|
|
5
|
+
FROM oven/bun:${BUN_VERSION} AS build
|
|
6
|
+
WORKDIR /app
|
|
7
|
+
COPY . .
|
|
8
|
+
# Without scripts: vite build generates .space/ itself.
|
|
9
|
+
# The cache mount keeps Bun's downloads between builds, and out of the image.
|
|
10
|
+
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
11
|
+
bun install --ignore-scripts && bunx vite build --config configs/vite.ts
|
|
12
|
+
|
|
13
|
+
FROM oven/bun:${BUN_VERSION}-slim
|
|
14
|
+
WORKDIR /app
|
|
15
|
+
COPY --from=build /app/dist .
|
|
16
|
+
# The server bundle is self-contained but for native packages, installed here for the image's platform.
|
|
17
|
+
RUN --mount=type=cache,target=/root/.bun/install/cache \
|
|
18
|
+
cd server && bun install --production --no-save \
|
|
19
|
+
&& mkdir -p /data && chown bun:bun /data
|
|
20
|
+
|
|
21
|
+
ENV NODE_ENV=production PORT=3000 SPACE_DATA_DIR=/data
|
|
22
|
+
VOLUME /data
|
|
23
|
+
EXPOSE 3000
|
|
24
|
+
USER bun
|
|
25
|
+
# One container runs the web server, which starts the queue and cron processes.
|
|
26
|
+
CMD ["bun", "server/index.js"]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The app's infrastructure: a plain Alchemy stack. `space deploy` runs `alchemy deploy configs/infra.ts`.
|
|
2
|
+
import * as Docker from "@alchemy.run/docker";
|
|
3
|
+
import * as Alchemy from "alchemy";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import { variables } from "spacefn/infra";
|
|
6
|
+
|
|
7
|
+
import env from "#configs/env.ts";
|
|
8
|
+
// What the file conventions ask for (databases, ...), as plain data from app/.
|
|
9
|
+
import { app } from "#space/infra.ts";
|
|
10
|
+
|
|
11
|
+
export default Alchemy.Stack(
|
|
12
|
+
app.name,
|
|
13
|
+
{
|
|
14
|
+
providers: Docker.providers(),
|
|
15
|
+
// Deploy state on this machine, in .alchemy/. To deploy from CI or several machines, keep it in
|
|
16
|
+
// a shared store instead, such as Cloudflare.state() from @alchemy.run/cloudflare.
|
|
17
|
+
state: Alchemy.localState(),
|
|
18
|
+
},
|
|
19
|
+
Effect.gen(function* () {
|
|
20
|
+
const environment: Record<string, any> = {
|
|
21
|
+
// configs/env.ts's variables, from .env.<stage> or the environment.
|
|
22
|
+
...variables(env),
|
|
23
|
+
...variables({ OTEL_EXPORTER_OTLP_ENDPOINT: "plain", OTEL_EXPORTER_OTLP_HEADERS: "secret" }),
|
|
24
|
+
};
|
|
25
|
+
// app/db/<name>/: a libSQL server reads DB_<NAME>_URL and DB_<NAME>_AUTH_TOKEN; without them, a file in /data.
|
|
26
|
+
for (const db of app.databases)
|
|
27
|
+
Object.assign(
|
|
28
|
+
environment,
|
|
29
|
+
variables({ [`${db.binding}_URL`]: "plain", [`${db.binding}_AUTH_TOKEN`]: "secret" }),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// To run it all on another machine, add `context` to each resource below:
|
|
33
|
+
// const context = yield* Docker.Context("Host", { docker: "host=ssh://deploy@example.com" });
|
|
34
|
+
const image = yield* Docker.Image("Image", {
|
|
35
|
+
name: app.name,
|
|
36
|
+
skipPush: true,
|
|
37
|
+
// Built from the source by configs/Dockerfile, which runs vite build.
|
|
38
|
+
build: { context: ".", dockerfile: "configs/Dockerfile" },
|
|
39
|
+
});
|
|
40
|
+
// File databases, the state database and blobs.
|
|
41
|
+
const data = yield* Docker.Volume("Data");
|
|
42
|
+
const port = 3000;
|
|
43
|
+
yield* Docker.Container("App", {
|
|
44
|
+
image,
|
|
45
|
+
start: true,
|
|
46
|
+
restart: "unless-stopped",
|
|
47
|
+
ports: [{ external: port, internal: 3000 }],
|
|
48
|
+
volumes: [{ hostPath: data.name, containerPath: "/data" }],
|
|
49
|
+
environment,
|
|
50
|
+
// SIGTERM lets requests finish and hands queue messages back.
|
|
51
|
+
stopTimeout: "30 seconds",
|
|
52
|
+
});
|
|
53
|
+
return { url: `http://localhost:${port}` };
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2022", "ESNext.Disposable", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "preserve",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"allowImportingTsExtensions": true,
|
|
8
|
+
"verbatimModuleSyntax": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"types": []
|
|
13
|
+
},
|
|
14
|
+
"include": ["../app", "../lib", "../modules", "../configs"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
import vite from "./vite.ts";
|
|
4
|
+
|
|
5
|
+
// The app's Vite config, so tests get the spacefn plugin (and spacefn/assets) too.
|
|
6
|
+
export default mergeConfig(
|
|
7
|
+
vite,
|
|
8
|
+
defineConfig({ test: { include: ["{app,lib,modules}/**/*.test.ts"] } }),
|
|
9
|
+
);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# About this app
|
|
2
|
+
|
|
3
|
+
Notes on how this app works, for whoever works on it next. `npm run docs` shows this folder next to spacefn's docs, and `npm run dev` serves the same at `/__space/docs/`.
|
|
4
|
+
|
|
5
|
+
Every Markdown file here is a page and every folder a group in the sidebar. spacefn's [Writing docs](spacefn/reference/writing-docs.md) page shows what a page can have: code tabs, callouts, diagrams and HTML.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* The design tokens and base styles every page shares. */
|
|
2
|
+
:root {
|
|
3
|
+
--space: 0.5rem;
|
|
4
|
+
--measure: 32rem;
|
|
5
|
+
color-scheme: light dark;
|
|
6
|
+
font-family: system-ui, sans-serif;
|
|
7
|
+
}
|
|
8
|
+
body {
|
|
9
|
+
max-width: var(--measure);
|
|
10
|
+
margin: calc(var(--space) * 6) auto;
|
|
11
|
+
padding: 0 calc(var(--space) * 2);
|
|
12
|
+
line-height: 1.5;
|
|
13
|
+
}
|
|
14
|
+
form {
|
|
15
|
+
display: flex;
|
|
16
|
+
gap: var(--space);
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { html, type HtmlValue } from "spacefn";
|
|
2
|
+
import { assets } from "spacefn/assets";
|
|
3
|
+
|
|
4
|
+
/** Datastar's client, for live updates. Or install it and import it from app/assets/. */
|
|
5
|
+
const DATASTAR = "https://cdn.jsdelivr.net/gh/starfederation/datastar@1.0.5/bundles/datastar.js";
|
|
6
|
+
|
|
7
|
+
/** The HTML around every page: its title, the site's styles and Datastar. */
|
|
8
|
+
export const layout = (title: string, body: HtmlValue) =>
|
|
9
|
+
html`<!doctype html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8" />
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
14
|
+
<title>${title}</title>
|
|
15
|
+
<link rel="icon" href="/favicon.svg" />
|
|
16
|
+
${assets("site")}
|
|
17
|
+
<script type="module" src="${DATASTAR}"></script>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
${body}
|
|
21
|
+
</body>
|
|
22
|
+
</html>`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* The todos page and list. */
|
|
2
|
+
input[name="title"] {
|
|
3
|
+
flex: 1;
|
|
4
|
+
}
|
|
5
|
+
#todos {
|
|
6
|
+
padding: 0;
|
|
7
|
+
list-style: none;
|
|
8
|
+
}
|
|
9
|
+
#todos button {
|
|
10
|
+
all: unset;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
#todos .done {
|
|
14
|
+
text-decoration: line-through;
|
|
15
|
+
opacity: 0.6;
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { form, memoryServices, testApp, testDb, testEnv } from "spacefn/testing";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
import Env from "#configs/env.ts";
|
|
6
|
+
import MainDb from "#space/db/main.ts";
|
|
7
|
+
import { manifest } from "#space/manifest.ts";
|
|
8
|
+
|
|
9
|
+
/** The app's pages and routes in memory: a fresh database, memory services and the env's defaults. */
|
|
10
|
+
const app = () =>
|
|
11
|
+
testApp(
|
|
12
|
+
manifest,
|
|
13
|
+
Layer.mergeAll(testDb(MainDb), memoryServices, Env.layer.pipe(Layer.provide(testEnv({})))),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// The feature through the page at /, as a browser uses it: in memory, with a fresh database.
|
|
17
|
+
describe("todos", () => {
|
|
18
|
+
it("adds a todo, then lists it", async () => {
|
|
19
|
+
await using page = app();
|
|
20
|
+
const added = await page.fetch("/?__action=add", form({ title: "Write docs" }));
|
|
21
|
+
expect([added.status, added.headers.get("location")]).toEqual([303, "/"]);
|
|
22
|
+
const list = await (await page.fetch("/")).text();
|
|
23
|
+
expect(list).toContain("Hello from spacefn");
|
|
24
|
+
expect(list).toContain("Write docs");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("asks for a title instead of adding an empty todo", async () => {
|
|
28
|
+
await using page = app();
|
|
29
|
+
const response = await page.fetch("/?__action=add", form({ title: "" }));
|
|
30
|
+
expect(response.status).toBe(422);
|
|
31
|
+
expect(await response.text()).toContain("Give the todo a title.");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Bus } from "spacefn";
|
|
3
|
+
|
|
4
|
+
import Env from "#configs/env.ts";
|
|
5
|
+
import MainDb, { type ListTodosRow } from "#space/db/main.ts";
|
|
6
|
+
|
|
7
|
+
/** The Bus topic every change to the todos is announced on. */
|
|
8
|
+
export const TOPIC = "todos";
|
|
9
|
+
|
|
10
|
+
export type Todo = ListTodosRow;
|
|
11
|
+
|
|
12
|
+
/** The page's heading, from configs/env.ts. */
|
|
13
|
+
export const greeting = Effect.gen(function* () {
|
|
14
|
+
return (yield* Env).GREETING;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** What adding a todo takes, from a form. */
|
|
18
|
+
export const NewTodo = Schema.Struct({ title: Schema.NonEmptyString });
|
|
19
|
+
|
|
20
|
+
/** Which todo, from a form. */
|
|
21
|
+
export const TodoRef = Schema.Struct({ id: Schema.FiniteFromString });
|
|
22
|
+
|
|
23
|
+
export const list = MainDb.listTodos();
|
|
24
|
+
|
|
25
|
+
/** Adds a todo, and tells every open page. */
|
|
26
|
+
export const add = ({ title }: typeof NewTodo.Type) =>
|
|
27
|
+
MainDb.addTodo({ title }).pipe(Effect.andThen(Bus.publish(TOPIC, "changed")));
|
|
28
|
+
|
|
29
|
+
/** Marks a todo done, or not done, and tells every open page. */
|
|
30
|
+
export const toggle = ({ id }: typeof TodoRef.Type) =>
|
|
31
|
+
MainDb.toggleTodo({ id }).pipe(Effect.andThen(Bus.publish(TOPIC, "changed")));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { html, type HtmlValue } from "spacefn";
|
|
2
|
+
|
|
3
|
+
import type { Todo } from "./todos.ts";
|
|
4
|
+
|
|
5
|
+
/** The list. Datastar swaps it in by its `id` when the todos change. */
|
|
6
|
+
export const todoList = (props: { readonly todos: readonly Todo[]; readonly toggle: string }) =>
|
|
7
|
+
html`<ul id="${todoList.id}">
|
|
8
|
+
${props.todos.map(
|
|
9
|
+
(todo) =>
|
|
10
|
+
html`<li>
|
|
11
|
+
<form method="post" action="${props.toggle}">
|
|
12
|
+
<input type="hidden" name="id" value="${todo.id}" />
|
|
13
|
+
<button class="${todo.done ? "done" : ""}">${todo.title}</button>
|
|
14
|
+
</form>
|
|
15
|
+
</li>`,
|
|
16
|
+
)}
|
|
17
|
+
</ul>`;
|
|
18
|
+
todoList.id = "todos";
|
|
19
|
+
|
|
20
|
+
/** The page's body: a form to add a todo, then the list, kept current by `live`. */
|
|
21
|
+
export const todosPage = (props: {
|
|
22
|
+
readonly greeting: string;
|
|
23
|
+
readonly list: HtmlValue;
|
|
24
|
+
/** Where the form posts. */
|
|
25
|
+
readonly add: string;
|
|
26
|
+
/** What Datastar opens for live updates. */
|
|
27
|
+
readonly live: string;
|
|
28
|
+
/** Whether the last todo sent had no title. */
|
|
29
|
+
readonly untitled: boolean;
|
|
30
|
+
}) =>
|
|
31
|
+
html`<main data-init="@get('${props.live}')">
|
|
32
|
+
<h1>${props.greeting}</h1>
|
|
33
|
+
<form method="post" action="${props.add}">
|
|
34
|
+
<input name="title" placeholder="What needs doing?" autofocus />
|
|
35
|
+
<button>Add</button>
|
|
36
|
+
</form>
|
|
37
|
+
${props.untitled ? html`<p role="alert">Give the todo a title.</p>` : ""} ${props.list}
|
|
38
|
+
</main>`;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starter-bun",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"imports": {
|
|
6
|
+
"#configs/*": "./configs/*",
|
|
7
|
+
"#lib/*": "./lib/*",
|
|
8
|
+
"#modules/*": "./modules/*",
|
|
9
|
+
"#space/*": "./.space/*"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"postinstall": "space gen",
|
|
13
|
+
"dev": "space dev",
|
|
14
|
+
"build": "space build",
|
|
15
|
+
"deploy": "space deploy",
|
|
16
|
+
"docs": "space docs",
|
|
17
|
+
"test": "vitest run --config configs/vitest.ts",
|
|
18
|
+
"typecheck": "tsc --noEmit"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"effect": "4.1.4",
|
|
22
|
+
"spacefn": "^0.11.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@alchemy.run/docker": "2.0.0-beta.87",
|
|
26
|
+
"alchemy": "2.0.0-beta.87",
|
|
27
|
+
"spacefn-docs": "^0.11.1",
|
|
28
|
+
"typescript": "^7.0.2",
|
|
29
|
+
"vite": "8.3.8",
|
|
30
|
+
"vitest": "5.1.1"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><circle cx="16" cy="16" r="14" fill="#111827"/><circle cx="16" cy="16" r="5" fill="#f9fafb"/></svg>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Notes for coding agents
|
|
2
|
+
|
|
3
|
+
This is a spacefn app, on Effect 4. spacefn's docs (`content/`) and example apps (`examples/`) for the installed version are in `node_modules/spacefn-docs/`: read them before guessing an API.
|
|
4
|
+
|
|
5
|
+
- `app/` only wires the runtime: its files connect code from `modules/` and `lib/` to routes, pages, jobs and the entry, with no logic or markup of their own.
|
|
6
|
+
- A feature's logic, views, client code and tests go in `modules/<feature>/`. Code shared by features (UI kit, design tokens, helpers) goes in `lib/`, which doesn't import `modules/`.
|
|
7
|
+
- `.space/` is generated: never edit it. After adding, removing or renaming a file in `app/`, run `npx space gen` (`npm run dev` does it on its own).
|
|
8
|
+
- `configs/env.ts` is imported by deploys, so it may import only `spacefn` and `effect`.
|
|
9
|
+
- Check your work with `npm run typecheck` and `npm test`; `npx space doctor` explains setup problems.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# spacefn app
|
|
2
|
+
|
|
3
|
+
A [spacefn](https://github.com/space-fn/spacefn) app: folders of convention files on [Effect](https://effect.website), served on Cloudflare Workers or Bun.
|
|
4
|
+
|
|
5
|
+
## Commands
|
|
6
|
+
|
|
7
|
+
| Command | What it does |
|
|
8
|
+
| ------------------ | ------------------------------------------------------------------------- |
|
|
9
|
+
| `npm run dev` | Runs the app locally, reloading on every change |
|
|
10
|
+
| `npm test` | Runs the tests |
|
|
11
|
+
| `npm run build` | Builds for production (Bun: `dist/`) |
|
|
12
|
+
| `npm run deploy` | Deploys (Cloudflare: your account; Bun: a Docker container), stage `prod` |
|
|
13
|
+
| `npm run docs` | Shows `docs/` and spacefn's docs in the browser |
|
|
14
|
+
| `npx space doctor` | Checks what dev and deploy need |
|
|
15
|
+
|
|
16
|
+
Local settings go in `.env` (copy `.env.example`). A deploy reads `.env.<stage>`, e.g. `.env.prod`, or the environment.
|
|
17
|
+
|
|
18
|
+
## Where things go
|
|
19
|
+
|
|
20
|
+
`app/` holds what spacefn reads, and each file there only connects code from `modules/` and `lib/`.
|
|
21
|
+
|
|
22
|
+
```txt
|
|
23
|
+
my-app/
|
|
24
|
+
├── app/
|
|
25
|
+
│ ├── entry.ts the app: its services, what wraps every request, onError
|
|
26
|
+
│ ├── routes/ pages and endpoints: index.ts is /, todos/[id].ts is /todos/:id
|
|
27
|
+
│ │ └── _middleware.ts wraps the requests to its folder
|
|
28
|
+
│ ├── db/
|
|
29
|
+
│ │ └── main/ config.json (driver, migrateOn), migrations/ and queries/ in SQL
|
|
30
|
+
│ ├── queues/ queue consumers, one per file
|
|
31
|
+
│ ├── crons/ scheduled jobs, one per file
|
|
32
|
+
│ └── assets/ browser entries, bundled by Vite; a page loads them with assets("name")
|
|
33
|
+
├── modules/
|
|
34
|
+
│ └── todos/ a feature: its logic, views, client code and tests
|
|
35
|
+
├── lib/
|
|
36
|
+
│ └── ui/ code features share: the layout and the base styles
|
|
37
|
+
├── public/ files served as they are at /
|
|
38
|
+
├── docs/ notes on this app, in Markdown: npm run docs shows them
|
|
39
|
+
├── configs/
|
|
40
|
+
│ ├── env.ts the variables the app reads
|
|
41
|
+
│ ├── vite.ts Vite, with spacefn's plugin and the target
|
|
42
|
+
│ ├── vitest.ts
|
|
43
|
+
│ └── tsconfig.json
|
|
44
|
+
└── .space/ generated by `space gen`; never edit it
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Import from the app root with `#modules/...`, `#lib/...` and `#configs/...`. `npm test` runs every `*.test.ts` in `app/`, `modules/` and `lib/`.
|