create-efforge 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +88 -2
- package/dist/addon.js +115 -0
- package/dist/bin.js +13 -0
- package/dist/cli.js +28 -0
- package/dist/commands/add.js +640 -0
- package/dist/commands/create.js +319 -0
- package/dist/commands/list.js +80 -0
- package/dist/diff.js +72 -0
- package/dist/exec.js +33 -0
- package/dist/generate.js +181 -0
- package/dist/manifest.js +14 -0
- package/dist/projectName.js +41 -0
- package/dist/prompts/flow.js +122 -0
- package/dist/prompts/navigable.js +193 -0
- package/dist/routeTree.js +7 -0
- package/dist/rules.js +27 -0
- package/dist/slots.js +116 -0
- package/dist/stack.js +68 -0
- package/dist/transforms/addAlchemyResource.js +71 -0
- package/dist/transforms/addArrayItem.js +31 -0
- package/dist/transforms/addAuthPlugin.js +77 -0
- package/dist/transforms/addDevVar.js +18 -0
- package/dist/transforms/addExport.js +46 -0
- package/dist/transforms/addImport.js +11 -0
- package/dist/transforms/addLayer.js +31 -0
- package/dist/transforms/addServerFnMiddleware.js +62 -0
- package/dist/transforms/addWorkflowSecret.js +43 -0
- package/dist/transforms/addWranglerBinding.js +61 -0
- package/dist/transforms/appendAgentsSection.js +26 -0
- package/dist/transforms/errors.js +7 -0
- package/dist/transforms/index.js +40 -0
- package/dist/transforms/setWranglerValue.js +40 -0
- package/dist/transforms/util.js +219 -0
- package/dist/tree.js +1 -0
- package/dist/versions.js +73 -0
- package/dist/write.js +28 -0
- package/package.json +63 -4
- package/templates/ai/effect-ai-byok/addon.json +619 -0
- package/templates/ai/effect-ai-byok/files/core/llm-crypto.test.ts +52 -0
- package/templates/ai/effect-ai-byok/files/core/llm-crypto.ts +76 -0
- package/templates/ai/effect-ai-byok/files/core/llm-store.ts +21 -0
- package/templates/ai/effect-ai-byok/files/core/llm.ts +32 -0
- package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/migration.sql +9 -0
- package/templates/ai/effect-ai-byok/files/drizzle/d1/20261018161056_llm_credential/snapshot.json +944 -0
- package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/migration.sql +10 -0
- package/templates/ai/effect-ai-byok/files/drizzle/pg/20261018161056_llm_credential/snapshot.json +1232 -0
- package/templates/ai/effect-ai-byok/files/routes/ai.tsx +193 -0
- package/templates/ai/effect-ai-byok/files/schema/d1.ts +16 -0
- package/templates/ai/effect-ai-byok/files/schema/pg.ts +14 -0
- package/templates/ai/effect-ai-byok/files/server/ai-settings.ts +129 -0
- package/templates/ai/effect-ai-byok/files/server/ai.ts +25 -0
- package/templates/ai/effect-ai-byok/files/server/llm-env.ts +48 -0
- package/templates/ai/effect-ai-byok/files/server/llm-orgs.ts +146 -0
- package/templates/ai/effect-ai-byok/files/server/llm-provider.ts +56 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-drizzle.ts +48 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-sql-d1.ts +41 -0
- package/templates/ai/effect-ai-byok/files/server/llm-store-sql-pg.ts +41 -0
- package/templates/ai/effect-ai-byok/files/sql/d1.sql +8 -0
- package/templates/ai/effect-ai-byok/files/sql/pg.sql +8 -0
- package/templates/auth/better-auth/addon.json +424 -0
- package/templates/auth/better-auth/files/core/Auth.ts +18 -0
- package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/migration.sql +51 -0
- package/templates/auth/better-auth/files/drizzle/d1/20261018161054_auth/snapshot.json +522 -0
- package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/migration.sql +51 -0
- package/templates/auth/better-auth/files/drizzle/pg/20261018161053_auth/snapshot.json +680 -0
- package/templates/auth/better-auth/files/lib/auth-client.ts +4 -0
- package/templates/auth/better-auth/files/routes/app.tsx +54 -0
- package/templates/auth/better-auth/files/schema/d1/auth-schema.ts +86 -0
- package/templates/auth/better-auth/files/schema/pg/auth-schema.ts +73 -0
- package/templates/auth/better-auth/files/server/auth-live.ts +47 -0
- package/templates/auth/better-auth/files/server/session.ts +14 -0
- package/templates/auth/better-auth/files/shared/components/auth-card.tsx +32 -0
- package/templates/auth/better-auth/files/shared/components/user-menu.tsx +44 -0
- package/templates/auth/better-auth/files/shared/drizzle/d1/drizzle.config.ts +7 -0
- package/templates/auth/better-auth/files/shared/drizzle/pg/drizzle.config.ts +10 -0
- package/templates/auth/better-auth/files/shared/lib/form.ts +5 -0
- package/templates/auth/better-auth/files/shared/lib/redirect.ts +6 -0
- package/templates/auth/better-auth/files/shared/routes/app/index.tsx +54 -0
- package/templates/auth/better-auth/files/shared/routes/sign-in.tsx +85 -0
- package/templates/auth/better-auth/files/shared/routes/sign-up.tsx +91 -0
- package/templates/auth/better-auth/files/shared/server/auth-route.ts +15 -0
- package/templates/auth/better-auth/files/shared/server/auth.ts +22 -0
- package/templates/auth/better-auth/files/shared/server/db/d1-drizzle.ts +25 -0
- package/templates/auth/better-auth/files/shared/server/db/d1-effect-sql.ts +17 -0
- package/templates/auth/better-auth/files/shared/server/db/pg-drizzle.ts +32 -0
- package/templates/auth/better-auth/files/shared/server/db/pg-effect-sql.ts +29 -0
- package/templates/auth/better-auth/files/shared/server/require-session.ts +20 -0
- package/templates/auth/better-auth/files/sql/d1/0002_auth.sql +13 -0
- package/templates/auth/better-auth/files/sql/pg/0002_auth.sql +13 -0
- package/templates/auth/better-auth-orgs/addon.json +463 -0
- package/templates/auth/better-auth-orgs/files/components/org-switcher.tsx +65 -0
- package/templates/auth/better-auth-orgs/files/core/Auth.ts +20 -0
- package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/migration.sql +88 -0
- package/templates/auth/better-auth-orgs/files/drizzle/d1/20261018161055_auth/snapshot.json +862 -0
- package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/migration.sql +88 -0
- package/templates/auth/better-auth-orgs/files/drizzle/pg/20261018161055_auth/snapshot.json +1127 -0
- package/templates/auth/better-auth-orgs/files/lib/auth-client.ts +5 -0
- package/templates/auth/better-auth-orgs/files/routes/accept-invite.$id.tsx +68 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings/index.tsx +27 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings/members.tsx +202 -0
- package/templates/auth/better-auth-orgs/files/routes/app/settings.tsx +30 -0
- package/templates/auth/better-auth-orgs/files/routes/app.tsx +58 -0
- package/templates/auth/better-auth-orgs/files/routes/onboarding.tsx +66 -0
- package/templates/auth/better-auth-orgs/files/schema/d1/auth-schema.ts +139 -0
- package/templates/auth/better-auth-orgs/files/schema/pg/auth-schema.ts +124 -0
- package/templates/auth/better-auth-orgs/files/server/auth-live.ts +52 -0
- package/templates/auth/better-auth-orgs/files/server/session.ts +44 -0
- package/templates/auth/better-auth-orgs/files/sql/d1/0002_auth.sql +27 -0
- package/templates/auth/better-auth-orgs/files/sql/pg/0002_auth.sql +27 -0
- package/templates/base/addon.json +216 -0
- package/templates/base/files/AGENTS.md +82 -0
- package/templates/base/files/CLAUDE.md +1 -0
- package/templates/base/files/README.md +32 -0
- package/templates/base/files/core/package.json +13 -0
- package/templates/base/files/core/src/index.ts +2 -0
- package/templates/base/files/core/test/core.test.ts +4 -0
- package/templates/base/files/core/tsconfig.json +6 -0
- package/templates/base/files/gitignore +11 -0
- package/templates/base/files/pnpm-workspace.yaml +11 -0
- package/templates/base/files/root/lint/effect-tests.js +45 -0
- package/templates/base/files/root/package.json +16 -0
- package/templates/base/files/root/tsconfig.base.json +19 -0
- package/templates/base/files/root/turbo.json +9 -0
- package/templates/base/files/root/vite.config.ts +86 -0
- package/templates/base/files/web/components.json +21 -0
- package/templates/base/files/web/package.json +17 -0
- package/templates/base/files/web/src/components/theme-provider.tsx +57 -0
- package/templates/base/files/web/src/components/theme-toggle.tsx +34 -0
- package/templates/base/files/web/src/components/ui/avatar.tsx +93 -0
- package/templates/base/files/web/src/components/ui/button.tsx +61 -0
- package/templates/base/files/web/src/components/ui/card.tsx +74 -0
- package/templates/base/files/web/src/components/ui/dialog.tsx +141 -0
- package/templates/base/files/web/src/components/ui/dropdown-menu.tsx +225 -0
- package/templates/base/files/web/src/components/ui/input.tsx +20 -0
- package/templates/base/files/web/src/components/ui/label.tsx +18 -0
- package/templates/base/files/web/src/components/ui/sonner.tsx +45 -0
- package/templates/base/files/web/src/components/widgets.tsx +4 -0
- package/templates/base/files/web/src/lib/utils.ts +6 -0
- package/templates/base/files/web/src/router.tsx +12 -0
- package/templates/base/files/web/src/routes/__root.tsx +42 -0
- package/templates/base/files/web/src/routes/app/index.tsx +27 -0
- package/templates/base/files/web/src/routes/app/settings.tsx +29 -0
- package/templates/base/files/web/src/routes/app.tsx +47 -0
- package/templates/base/files/web/src/routes/index.tsx +51 -0
- package/templates/base/files/web/src/server/greeting.ts +12 -0
- package/templates/base/files/web/src/server/layers.ts +10 -0
- package/templates/base/files/web/src/server/runtime.ts +5 -0
- package/templates/base/files/web/src/styles.css +81 -0
- package/templates/base/files/web/tsconfig.json +11 -0
- package/templates/base/files/web/vite.config.ts +9 -0
- package/templates/database/d1/addon.json +118 -0
- package/templates/database/d1/files/package.json +12 -0
- package/templates/database/d1/files/tsconfig.json +5 -0
- package/templates/database/postgres/addon.json +142 -0
- package/templates/database/postgres/files/docker-compose.yml +21 -0
- package/templates/database/postgres/files/package.json +12 -0
- package/templates/database/postgres/files/runtime.ts +12 -0
- package/templates/database/postgres/files/tsconfig.json +5 -0
- package/templates/extras/browser/addon.json +173 -0
- package/templates/extras/browser/files/BrowserContainer.ts +14 -0
- package/templates/extras/browser/files/app/Dockerfile +15 -0
- package/templates/extras/browser/files/app/dockerignore +1 -0
- package/templates/extras/browser/files/app/package-lock +605 -0
- package/templates/extras/browser/files/app/package.json +9 -0
- package/templates/extras/browser/files/app/src/server.ts +78 -0
- package/templates/extras/browser/files/app/src/url-policy.ts +115 -0
- package/templates/extras/browser/files/app/tsconfig.json +6 -0
- package/templates/extras/browser/files/browser.ts +34 -0
- package/templates/extras/browser/files/core-browser.ts +21 -0
- package/templates/extras/browser/files/run-browser.ts +25 -0
- package/templates/extras/email/addon.json +182 -0
- package/templates/extras/email/files/core-mailer.ts +28 -0
- package/templates/extras/email/files/invitation-email.ts +38 -0
- package/templates/extras/email/files/mailer.ts +58 -0
- package/templates/extras/realtime/addon.json +135 -0
- package/templates/extras/realtime/files/Room.ts +46 -0
- package/templates/extras/realtime/files/core-realtime.ts +19 -0
- package/templates/extras/realtime/files/realtime-demo.tsx +40 -0
- package/templates/extras/realtime/files/realtime-limits.test.ts +32 -0
- package/templates/extras/realtime/files/realtime-limits.ts +35 -0
- package/templates/extras/realtime/files/realtime-route.ts +39 -0
- package/templates/extras/realtime/files/realtime.ts +39 -0
- package/templates/extras/realtime/files/use-room.ts +67 -0
- package/templates/extras/storage/addon.json +132 -0
- package/templates/extras/storage/files/core-storage.ts +64 -0
- package/templates/extras/storage/files/storage-route.ts +50 -0
- package/templates/extras/storage/files/storage-security.test.ts +71 -0
- package/templates/extras/storage/files/storage-security.ts +92 -0
- package/templates/extras/storage/files/storage.ts +84 -0
- package/templates/extras/workflows/addon.json +95 -0
- package/templates/extras/workflows/files/Example.ts +42 -0
- package/templates/extras/workflows/files/core-jobs.ts +45 -0
- package/templates/extras/workflows/files/example-job.ts +36 -0
- package/templates/extras/workflows/files/jobs.ts +34 -0
- package/templates/infra/alchemy/addon.json +37 -0
- package/templates/infra/alchemy/files/README.md +27 -0
- package/templates/infra/alchemy/files/alchemy.run.ts +36 -0
- package/templates/infra/alchemy/files/github/deploy.yml +63 -0
- package/templates/infra/alchemy/files/tsconfig.json +5 -0
- package/templates/infra/alchemy/files/vite.config.ts +30 -0
- package/templates/orm/drizzle/addon.json +188 -0
- package/templates/orm/drizzle/files/d1/Database.ts +7 -0
- package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/migration.sql +10 -0
- package/templates/orm/drizzle/files/d1/drizzle/20261018154417_init/snapshot.json +60 -0
- package/templates/orm/drizzle/files/d1/drizzle.config.ts +7 -0
- package/templates/orm/drizzle/files/d1/layer.ts +13 -0
- package/templates/orm/drizzle/files/d1/migrate.ts +37 -0
- package/templates/orm/drizzle/files/d1/schema.ts +15 -0
- package/templates/orm/drizzle/files/pg/Database.ts +7 -0
- package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/migration.sql +10 -0
- package/templates/orm/drizzle/files/pg/drizzle/20261018154416_init/snapshot.json +75 -0
- package/templates/orm/drizzle/files/pg/drizzle.config.ts +10 -0
- package/templates/orm/drizzle/files/pg/layer.ts +16 -0
- package/templates/orm/drizzle/files/pg/migrate.ts +24 -0
- package/templates/orm/drizzle/files/pg/schema.ts +11 -0
- package/templates/orm/drizzle/files/shared/index.ts +2 -0
- package/templates/orm/drizzle/files/shared/notes.ts +15 -0
- package/templates/orm/drizzle/files/shared/page.tsx +50 -0
- package/templates/orm/effect-sql/addon.json +124 -0
- package/templates/orm/effect-sql/files/d1/layer.ts +13 -0
- package/templates/orm/effect-sql/files/d1/migrate.ts +20 -0
- package/templates/orm/effect-sql/files/d1/schema.ts +7 -0
- package/templates/orm/effect-sql/files/d1-sql/0001_init.sql +10 -0
- package/templates/orm/effect-sql/files/pg/layer.ts +16 -0
- package/templates/orm/effect-sql/files/pg/migrate.ts +66 -0
- package/templates/orm/effect-sql/files/pg/schema.ts +7 -0
- package/templates/orm/effect-sql/files/pg-sql/0001_init.sql +10 -0
- package/templates/orm/effect-sql/files/shared/Database.ts +7 -0
- package/templates/orm/effect-sql/files/shared/index.ts +2 -0
- package/templates/orm/effect-sql/files/shared/notes.ts +18 -0
- package/templates/orm/effect-sql/files/shared/page.tsx +50 -0
- package/templates/runtime/cloudflare/addon.json +52 -0
- package/templates/runtime/cloudflare/files/cloudflare.ts +10 -0
- package/templates/runtime/cloudflare/files/routes.ts +5 -0
- package/templates/runtime/cloudflare/files/server.ts +22 -0
- package/templates/runtime/cloudflare/files/tsconfig.json +12 -0
- package/templates/runtime/cloudflare/files/vite.config.ts +20 -0
- package/templates/runtime/cloudflare/files/wrangler.jsonc +8 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { pgTable, text, timestamp, boolean, index } from "drizzle-orm/pg-core"
|
|
2
|
+
|
|
3
|
+
export const user = pgTable("user", {
|
|
4
|
+
id: text("id").primaryKey(),
|
|
5
|
+
name: text("name").notNull(),
|
|
6
|
+
email: text("email").notNull().unique(),
|
|
7
|
+
emailVerified: boolean("email_verified").default(false).notNull(),
|
|
8
|
+
image: text("image"),
|
|
9
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
10
|
+
updatedAt: timestamp("updated_at")
|
|
11
|
+
.defaultNow()
|
|
12
|
+
.$onUpdate(() => /* @__PURE__ */ new Date())
|
|
13
|
+
.notNull(),
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const session = pgTable(
|
|
17
|
+
"session",
|
|
18
|
+
{
|
|
19
|
+
id: text("id").primaryKey(),
|
|
20
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
21
|
+
token: text("token").notNull().unique(),
|
|
22
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
23
|
+
updatedAt: timestamp("updated_at")
|
|
24
|
+
.$onUpdate(() => /* @__PURE__ */ new Date())
|
|
25
|
+
.notNull(),
|
|
26
|
+
ipAddress: text("ip_address"),
|
|
27
|
+
userAgent: text("user_agent"),
|
|
28
|
+
userId: text("user_id")
|
|
29
|
+
.notNull()
|
|
30
|
+
.references(() => user.id, { onDelete: "cascade" }),
|
|
31
|
+
activeOrganizationId: text("active_organization_id"),
|
|
32
|
+
},
|
|
33
|
+
(table) => [index("session_userId_idx").on(table.userId)],
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export const account = pgTable(
|
|
37
|
+
"account",
|
|
38
|
+
{
|
|
39
|
+
id: text("id").primaryKey(),
|
|
40
|
+
accountId: text("account_id").notNull(),
|
|
41
|
+
providerId: text("provider_id").notNull(),
|
|
42
|
+
userId: text("user_id")
|
|
43
|
+
.notNull()
|
|
44
|
+
.references(() => user.id, { onDelete: "cascade" }),
|
|
45
|
+
accessToken: text("access_token"),
|
|
46
|
+
refreshToken: text("refresh_token"),
|
|
47
|
+
idToken: text("id_token"),
|
|
48
|
+
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
|
49
|
+
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
|
50
|
+
scope: text("scope"),
|
|
51
|
+
password: text("password"),
|
|
52
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
53
|
+
updatedAt: timestamp("updated_at")
|
|
54
|
+
.$onUpdate(() => /* @__PURE__ */ new Date())
|
|
55
|
+
.notNull(),
|
|
56
|
+
},
|
|
57
|
+
(table) => [index("account_userId_idx").on(table.userId)],
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
export const verification = pgTable(
|
|
61
|
+
"verification",
|
|
62
|
+
{
|
|
63
|
+
id: text("id").primaryKey(),
|
|
64
|
+
identifier: text("identifier").notNull(),
|
|
65
|
+
value: text("value").notNull(),
|
|
66
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
67
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
68
|
+
updatedAt: timestamp("updated_at")
|
|
69
|
+
.defaultNow()
|
|
70
|
+
.$onUpdate(() => /* @__PURE__ */ new Date())
|
|
71
|
+
.notNull(),
|
|
72
|
+
},
|
|
73
|
+
(table) => [index("verification_identifier_idx").on(table.identifier)],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
export const organization = pgTable("organization", {
|
|
77
|
+
id: text("id").primaryKey(),
|
|
78
|
+
name: text("name").notNull(),
|
|
79
|
+
slug: text("slug").notNull().unique(),
|
|
80
|
+
logo: text("logo"),
|
|
81
|
+
createdAt: timestamp("created_at").notNull(),
|
|
82
|
+
metadata: text("metadata"),
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
export const member = pgTable(
|
|
86
|
+
"member",
|
|
87
|
+
{
|
|
88
|
+
id: text("id").primaryKey(),
|
|
89
|
+
organizationId: text("organization_id")
|
|
90
|
+
.notNull()
|
|
91
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
92
|
+
userId: text("user_id")
|
|
93
|
+
.notNull()
|
|
94
|
+
.references(() => user.id, { onDelete: "cascade" }),
|
|
95
|
+
role: text("role").default("member").notNull(),
|
|
96
|
+
createdAt: timestamp("created_at").notNull(),
|
|
97
|
+
},
|
|
98
|
+
(table) => [
|
|
99
|
+
index("member_organizationId_idx").on(table.organizationId),
|
|
100
|
+
index("member_userId_idx").on(table.userId),
|
|
101
|
+
],
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
export const invitation = pgTable(
|
|
105
|
+
"invitation",
|
|
106
|
+
{
|
|
107
|
+
id: text("id").primaryKey(),
|
|
108
|
+
organizationId: text("organization_id")
|
|
109
|
+
.notNull()
|
|
110
|
+
.references(() => organization.id, { onDelete: "cascade" }),
|
|
111
|
+
email: text("email").notNull(),
|
|
112
|
+
role: text("role"),
|
|
113
|
+
status: text("status").default("pending").notNull(),
|
|
114
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
115
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
116
|
+
inviterId: text("inviter_id")
|
|
117
|
+
.notNull()
|
|
118
|
+
.references(() => user.id, { onDelete: "cascade" }),
|
|
119
|
+
},
|
|
120
|
+
(table) => [
|
|
121
|
+
index("invitation_organizationId_idx").on(table.organizationId),
|
|
122
|
+
index("invitation_email_idx").on(table.email),
|
|
123
|
+
],
|
|
124
|
+
)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Auth, Unauthorized } from "@repo/core/Auth"
|
|
2
|
+
import { getRequestHeaders } from "@tanstack/react-start/server"
|
|
3
|
+
import { Config, Context, Effect, Layer, Option, Redacted } from "effect"
|
|
4
|
+
import { WorkerConfig } from "effect-cf"
|
|
5
|
+
import { type AuthInstance, makeAuth } from "./auth"
|
|
6
|
+
import { AuthDatabase, AuthDatabaseLayer } from "./auth-database"
|
|
7
|
+
import { WorkerEnvLive } from "./cloudflare"
|
|
8
|
+
|
|
9
|
+
/** The Better Auth instance; `/api/auth/*` is served from it (see auth-route.ts). */
|
|
10
|
+
export class BetterAuth extends Context.Service<BetterAuth, AuthInstance>()("BetterAuth") {}
|
|
11
|
+
|
|
12
|
+
const BetterAuthLive = Layer.effect(
|
|
13
|
+
BetterAuth,
|
|
14
|
+
Effect.gen(function* () {
|
|
15
|
+
const { database } = yield* AuthDatabase
|
|
16
|
+
const provider = yield* WorkerConfig.provider
|
|
17
|
+
const { secret, baseURL } = yield* Effect.all({
|
|
18
|
+
secret: Config.Redacted("BETTER_AUTH_SECRET").parse(provider),
|
|
19
|
+
baseURL: Config.option(Config.String("BETTER_AUTH_URL")).parse(provider),
|
|
20
|
+
})
|
|
21
|
+
return makeAuth({
|
|
22
|
+
database,
|
|
23
|
+
secret: Redacted.value(secret),
|
|
24
|
+
baseURL: Option.getOrUndefined(Option.filter(baseURL, (url) => url !== "")),
|
|
25
|
+
})
|
|
26
|
+
}),
|
|
27
|
+
).pipe(Layer.provide(AuthDatabaseLayer), Layer.provide(WorkerEnvLive))
|
|
28
|
+
|
|
29
|
+
const unauthorized = () => new Unauthorized({ message: "Not signed in" })
|
|
30
|
+
|
|
31
|
+
/** Provides `Auth` (and `BetterAuth`). The session is read from the cookies of the request being handled. */
|
|
32
|
+
export const AuthLive = Layer.effect(
|
|
33
|
+
Auth,
|
|
34
|
+
Effect.gen(function* () {
|
|
35
|
+
const auth = yield* BetterAuth
|
|
36
|
+
return Auth.of({
|
|
37
|
+
currentSession: Effect.gen(function* () {
|
|
38
|
+
const found = yield* Effect.tryPromise({
|
|
39
|
+
try: () => auth.api.getSession({ headers: getRequestHeaders() }),
|
|
40
|
+
catch: unauthorized,
|
|
41
|
+
})
|
|
42
|
+
if (found === null) return yield* unauthorized()
|
|
43
|
+
return {
|
|
44
|
+
userId: found.user.id,
|
|
45
|
+
email: found.user.email,
|
|
46
|
+
name: found.user.name,
|
|
47
|
+
activeOrganizationId: found.session.activeOrganizationId ?? null,
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
})
|
|
51
|
+
}),
|
|
52
|
+
).pipe(Layer.provideMerge(BetterAuthLive))
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Auth } from "@repo/core/Auth"
|
|
2
|
+
import { createServerFn } from "@tanstack/react-start"
|
|
3
|
+
import { getRequestHeaders } from "@tanstack/react-start/server"
|
|
4
|
+
import { Effect } from "effect"
|
|
5
|
+
import { BetterAuth } from "./auth-live"
|
|
6
|
+
import { runtime } from "./runtime"
|
|
7
|
+
|
|
8
|
+
/** The signed-in user, or null. Route guards call this. */
|
|
9
|
+
export const getSession = createServerFn({ method: "GET" }).handler(() =>
|
|
10
|
+
runtime.runPromise(
|
|
11
|
+
Effect.gen(function* () {
|
|
12
|
+
const auth = yield* Auth
|
|
13
|
+
return yield* auth.currentSession
|
|
14
|
+
}).pipe(Effect.catchTag("Unauthorized", () => Effect.succeed(null))),
|
|
15
|
+
),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* What the app shell needs: the session and the organizations the user belongs to. A user who
|
|
20
|
+
* belongs to organizations but has none active (for example after signing in again) gets the first one.
|
|
21
|
+
*/
|
|
22
|
+
export const getAppState = createServerFn({ method: "GET" }).handler(() =>
|
|
23
|
+
runtime.runPromise(
|
|
24
|
+
Effect.gen(function* () {
|
|
25
|
+
const { currentSession } = yield* Auth
|
|
26
|
+
const session = yield* currentSession
|
|
27
|
+
const auth = yield* BetterAuth
|
|
28
|
+
const headers = getRequestHeaders()
|
|
29
|
+
const organizations = yield* Effect.promise(() => auth.api.listOrganizations({ headers }))
|
|
30
|
+
const first = organizations[0]
|
|
31
|
+
let activeOrganizationId = session.activeOrganizationId
|
|
32
|
+
if (activeOrganizationId === null && first !== undefined) {
|
|
33
|
+
activeOrganizationId = first.id
|
|
34
|
+
yield* Effect.promise(() =>
|
|
35
|
+
auth.api.setActiveOrganization({ headers, body: { organizationId: first.id } }),
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
session: { ...session, activeOrganizationId },
|
|
40
|
+
organizations: organizations.map(({ id, name, slug }) => ({ id, name, slug })),
|
|
41
|
+
}
|
|
42
|
+
}).pipe(Effect.catchTag("Unauthorized", () => Effect.succeed(null))),
|
|
43
|
+
),
|
|
44
|
+
)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" integer not null, "image" text, "createdAt" date not null, "updatedAt" date not null);
|
|
2
|
+
|
|
3
|
+
create table "session" ("id" text not null primary key, "expiresAt" date not null, "token" text not null unique, "createdAt" date not null, "updatedAt" date not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade, "activeOrganizationId" text);
|
|
4
|
+
|
|
5
|
+
create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" date, "refreshTokenExpiresAt" date, "scope" text, "password" text, "createdAt" date not null, "updatedAt" date not null);
|
|
6
|
+
|
|
7
|
+
create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" date not null, "createdAt" date not null, "updatedAt" date not null);
|
|
8
|
+
|
|
9
|
+
create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" date not null, "metadata" text);
|
|
10
|
+
|
|
11
|
+
create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" date not null);
|
|
12
|
+
|
|
13
|
+
create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "status" text not null, "expiresAt" date not null, "createdAt" date not null, "inviterId" text not null references "user" ("id") on delete cascade);
|
|
14
|
+
|
|
15
|
+
create index "session_userId_idx" on "session" ("userId");
|
|
16
|
+
|
|
17
|
+
create index "account_userId_idx" on "account" ("userId");
|
|
18
|
+
|
|
19
|
+
create index "verification_identifier_idx" on "verification" ("identifier");
|
|
20
|
+
|
|
21
|
+
create index "member_organizationId_idx" on "member" ("organizationId");
|
|
22
|
+
|
|
23
|
+
create index "member_userId_idx" on "member" ("userId");
|
|
24
|
+
|
|
25
|
+
create index "invitation_organizationId_idx" on "invitation" ("organizationId");
|
|
26
|
+
|
|
27
|
+
create index "invitation_email_idx" on "invitation" ("email");
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
create table "user" ("id" text not null primary key, "name" text not null, "email" text not null unique, "emailVerified" boolean not null, "image" text, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz default CURRENT_TIMESTAMP not null);
|
|
2
|
+
|
|
3
|
+
create table "session" ("id" text not null primary key, "expiresAt" timestamptz not null, "token" text not null unique, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz not null, "ipAddress" text, "userAgent" text, "userId" text not null references "user" ("id") on delete cascade, "activeOrganizationId" text);
|
|
4
|
+
|
|
5
|
+
create table "account" ("id" text not null primary key, "accountId" text not null, "providerId" text not null, "userId" text not null references "user" ("id") on delete cascade, "accessToken" text, "refreshToken" text, "idToken" text, "accessTokenExpiresAt" timestamptz, "refreshTokenExpiresAt" timestamptz, "scope" text, "password" text, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz not null);
|
|
6
|
+
|
|
7
|
+
create table "verification" ("id" text not null primary key, "identifier" text not null, "value" text not null, "expiresAt" timestamptz not null, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "updatedAt" timestamptz default CURRENT_TIMESTAMP not null);
|
|
8
|
+
|
|
9
|
+
create table "organization" ("id" text not null primary key, "name" text not null, "slug" text not null unique, "logo" text, "createdAt" timestamptz not null, "metadata" text);
|
|
10
|
+
|
|
11
|
+
create table "member" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "userId" text not null references "user" ("id") on delete cascade, "role" text not null, "createdAt" timestamptz not null);
|
|
12
|
+
|
|
13
|
+
create table "invitation" ("id" text not null primary key, "organizationId" text not null references "organization" ("id") on delete cascade, "email" text not null, "role" text, "status" text not null, "expiresAt" timestamptz not null, "createdAt" timestamptz default CURRENT_TIMESTAMP not null, "inviterId" text not null references "user" ("id") on delete cascade);
|
|
14
|
+
|
|
15
|
+
create index "session_userId_idx" on "session" ("userId");
|
|
16
|
+
|
|
17
|
+
create index "account_userId_idx" on "account" ("userId");
|
|
18
|
+
|
|
19
|
+
create index "verification_identifier_idx" on "verification" ("identifier");
|
|
20
|
+
|
|
21
|
+
create index "member_organizationId_idx" on "member" ("organizationId");
|
|
22
|
+
|
|
23
|
+
create index "member_userId_idx" on "member" ("userId");
|
|
24
|
+
|
|
25
|
+
create index "invitation_organizationId_idx" on "invitation" ("organizationId");
|
|
26
|
+
|
|
27
|
+
create index "invitation_email_idx" on "invitation" ("email");
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "base",
|
|
3
|
+
"title": "Base",
|
|
4
|
+
"description": "Monorepo skeleton shared by every stack: pnpm, Turborepo, Vite+ (oxlint/oxfmt), TanStack Start, Tailwind v4 and shadcn/ui.",
|
|
5
|
+
"files": [
|
|
6
|
+
{
|
|
7
|
+
"path": "files/AGENTS.md",
|
|
8
|
+
"target": "AGENTS.md"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"path": "files/CLAUDE.md",
|
|
12
|
+
"target": "CLAUDE.md"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "files/README.md",
|
|
16
|
+
"target": "README.md"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "files/core/package.json",
|
|
20
|
+
"target": "packages/core/package.json"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"path": "files/core/src/index.ts",
|
|
24
|
+
"target": "packages/core/src/index.ts"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "files/core/test/core.test.ts",
|
|
28
|
+
"target": "packages/core/test/core.test.ts"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "files/core/tsconfig.json",
|
|
32
|
+
"target": "packages/core/tsconfig.json"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"path": "files/gitignore",
|
|
36
|
+
"target": ".gitignore"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "files/pnpm-workspace.yaml",
|
|
40
|
+
"target": "pnpm-workspace.yaml"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"path": "files/root/package.json",
|
|
44
|
+
"target": "package.json"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"path": "files/root/tsconfig.base.json",
|
|
48
|
+
"target": "tsconfig.base.json"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"path": "files/root/turbo.json",
|
|
52
|
+
"target": "turbo.json"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"path": "files/root/vite.config.ts",
|
|
56
|
+
"target": "vite.config.ts"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"path": "files/root/lint/effect-tests.js",
|
|
60
|
+
"target": "lint/effect-tests.js"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"path": "files/web/components.json",
|
|
64
|
+
"target": "apps/web/components.json"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"path": "files/web/package.json",
|
|
68
|
+
"target": "apps/web/package.json"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"path": "files/web/src/components/theme-provider.tsx",
|
|
72
|
+
"target": "apps/web/src/components/theme-provider.tsx"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"path": "files/web/src/components/theme-toggle.tsx",
|
|
76
|
+
"target": "apps/web/src/components/theme-toggle.tsx"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"path": "files/web/src/components/ui/avatar.tsx",
|
|
80
|
+
"target": "apps/web/src/components/ui/avatar.tsx"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"path": "files/web/src/components/ui/button.tsx",
|
|
84
|
+
"target": "apps/web/src/components/ui/button.tsx"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"path": "files/web/src/components/ui/card.tsx",
|
|
88
|
+
"target": "apps/web/src/components/ui/card.tsx"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"path": "files/web/src/components/ui/dialog.tsx",
|
|
92
|
+
"target": "apps/web/src/components/ui/dialog.tsx"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"path": "files/web/src/components/ui/dropdown-menu.tsx",
|
|
96
|
+
"target": "apps/web/src/components/ui/dropdown-menu.tsx"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"path": "files/web/src/components/ui/input.tsx",
|
|
100
|
+
"target": "apps/web/src/components/ui/input.tsx"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"path": "files/web/src/components/ui/label.tsx",
|
|
104
|
+
"target": "apps/web/src/components/ui/label.tsx"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"path": "files/web/src/components/ui/sonner.tsx",
|
|
108
|
+
"target": "apps/web/src/components/ui/sonner.tsx"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"path": "files/web/src/components/widgets.tsx",
|
|
112
|
+
"target": "apps/web/src/components/widgets.tsx"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"path": "files/web/src/lib/utils.ts",
|
|
116
|
+
"target": "apps/web/src/lib/utils.ts"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"path": "files/web/src/router.tsx",
|
|
120
|
+
"target": "apps/web/src/router.tsx"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"path": "files/web/src/routes/__root.tsx",
|
|
124
|
+
"target": "apps/web/src/routes/__root.tsx"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"path": "files/web/src/routes/app.tsx",
|
|
128
|
+
"target": "apps/web/src/routes/app.tsx"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"path": "files/web/src/routes/app/index.tsx",
|
|
132
|
+
"target": "apps/web/src/routes/app/index.tsx"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"path": "files/web/src/routes/app/settings.tsx",
|
|
136
|
+
"target": "apps/web/src/routes/app/settings.tsx"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"path": "files/web/src/routes/index.tsx",
|
|
140
|
+
"target": "apps/web/src/routes/index.tsx"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"path": "files/web/src/server/greeting.ts",
|
|
144
|
+
"target": "apps/web/src/server/greeting.ts"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"path": "files/web/src/server/layers.ts",
|
|
148
|
+
"target": "apps/web/src/server/layers.ts"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"path": "files/web/src/server/runtime.ts",
|
|
152
|
+
"target": "apps/web/src/server/runtime.ts"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"path": "files/web/src/styles.css",
|
|
156
|
+
"target": "apps/web/src/styles.css"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"path": "files/web/tsconfig.json",
|
|
160
|
+
"target": "apps/web/tsconfig.json"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"path": "files/web/vite.config.ts",
|
|
164
|
+
"target": "apps/web/vite.config.ts"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
"dependencies": {
|
|
168
|
+
"apps/web": [
|
|
169
|
+
"@tanstack/react-router",
|
|
170
|
+
"@tanstack/react-start",
|
|
171
|
+
"class-variance-authority",
|
|
172
|
+
"clsx",
|
|
173
|
+
"effect",
|
|
174
|
+
"lucide-react",
|
|
175
|
+
"radix-ui",
|
|
176
|
+
"react",
|
|
177
|
+
"react-dom",
|
|
178
|
+
"sonner",
|
|
179
|
+
"tailwind-merge",
|
|
180
|
+
"tw-animate-css"
|
|
181
|
+
],
|
|
182
|
+
"packages/core": [
|
|
183
|
+
"effect"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"devDependencies": {
|
|
187
|
+
".": [
|
|
188
|
+
"@effect/tsgo",
|
|
189
|
+
"oxlint",
|
|
190
|
+
"oxlint-tsgolint",
|
|
191
|
+
"turbo",
|
|
192
|
+
"typescript",
|
|
193
|
+
"vite-plus"
|
|
194
|
+
],
|
|
195
|
+
"apps/web": [
|
|
196
|
+
"@tailwindcss/vite",
|
|
197
|
+
"@types/react",
|
|
198
|
+
"@types/react-dom",
|
|
199
|
+
"@tanstack/router-cli",
|
|
200
|
+
"@vitejs/plugin-react",
|
|
201
|
+
"tailwindcss",
|
|
202
|
+
"typescript",
|
|
203
|
+
"vite"
|
|
204
|
+
],
|
|
205
|
+
"packages/core": [
|
|
206
|
+
"@effect/vitest",
|
|
207
|
+
"@types/node",
|
|
208
|
+
"typescript",
|
|
209
|
+
"vitest"
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
"envVars": [],
|
|
213
|
+
"requires": [],
|
|
214
|
+
"conflicts": [],
|
|
215
|
+
"transforms": []
|
|
216
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Agent guide
|
|
2
|
+
|
|
3
|
+
Rules for AI agents (and humans) working in this repo. Read this before changing code.
|
|
4
|
+
|
|
5
|
+
## Layout
|
|
6
|
+
|
|
7
|
+
- `packages/core`: service interfaces (`Context.Service` tags), tagged errors, schemas. No runtime wiring.
|
|
8
|
+
- `apps/web/src/server/layers.ts`: the single place layers are composed into `AppLayer`.
|
|
9
|
+
- `apps/web/src/server/runtime.ts`: runs an Effect against `AppLayer`; server functions go through it.
|
|
10
|
+
- `apps/web/src/server.ts`: the Worker entry. Durable Object and Workflow classes are exported from here.
|
|
11
|
+
- `apps/web/src/server/routes.ts`: Worker-level routes (`workerRoutes`) tried before TanStack Start.
|
|
12
|
+
- `apps/web/src/routes`: TanStack Router file routes. `routeTree.gen.ts` is generated (and gitignored); never edit it.
|
|
13
|
+
- `apps/web/src/components/ui`: shadcn components.
|
|
14
|
+
- `efforge.jsonc`: the stack choices. `efforge add` reads it; leave it alone.
|
|
15
|
+
|
|
16
|
+
## Effect
|
|
17
|
+
|
|
18
|
+
- Model capabilities as services in `packages/core` and implement them as layers; wire layers in `layers.ts`.
|
|
19
|
+
- Failures are tagged errors (`Data.TaggedError`) in the error channel, handled with `Effect.catchTag`.
|
|
20
|
+
- Validate data at boundaries (requests, env, storage, third-party responses) with `Schema`.
|
|
21
|
+
- Reach Cloudflare bindings (R2, D1, KV, Durable Objects, ...) only through `effect-cf`.
|
|
22
|
+
`apps/web/src/server/cloudflare.ts` is the one file that imports `env` from `cloudflare:workers`;
|
|
23
|
+
lint rejects it anywhere else.
|
|
24
|
+
- Never wrap an Effect in `try/catch`, and never use `async`/`await` inside `Effect.gen`; use `yield*`.
|
|
25
|
+
- Provide layers at entry points only (`runtime.ts`, scripts), not inside library code.
|
|
26
|
+
- No `any`. Use `unknown` and narrow it with `Schema` or a type guard.
|
|
27
|
+
- Keep `E` types specific; `unknown` or `any` in an error channel is a lint error.
|
|
28
|
+
- Model a multi-step lifecycle (order, invite, job) as a tagged union of states
|
|
29
|
+
(`Data.TaggedEnum`) and match on it, not as a set of boolean flags.
|
|
30
|
+
|
|
31
|
+
## Tests
|
|
32
|
+
|
|
33
|
+
- Write Effect tests with `it.effect` and `it.layer` from `@effect/vitest`. `Effect.run*` and
|
|
34
|
+
`ManagedRuntime.make` in a test file are lint errors (`lint/effect-tests.js`).
|
|
35
|
+
- Swap services with test layers; do not mock modules.
|
|
36
|
+
- Where a fake would behave differently from the platform (D1, R2, Durable Objects, Workflows),
|
|
37
|
+
check the behaviour under `pnpm dev` too: it runs your Worker in workerd with local bindings.
|
|
38
|
+
|
|
39
|
+
## UI
|
|
40
|
+
|
|
41
|
+
- Use the existing shadcn components in `components/ui` before writing new ones.
|
|
42
|
+
- Style with Tailwind classes and the theme tokens (`bg-background`, `text-muted-foreground`, ...), not hard-coded colors.
|
|
43
|
+
- No inline `style` props and no CSS-in-JS.
|
|
44
|
+
- Do not add a dependency unless the task cannot be done without it.
|
|
45
|
+
|
|
46
|
+
## Style
|
|
47
|
+
|
|
48
|
+
- Match the surrounding code: naming, file layout, error handling.
|
|
49
|
+
- No comments that restate the code. Comment only the non-obvious why.
|
|
50
|
+
- No placeholder code, TODOs or stubs; finish what you start or leave it out.
|
|
51
|
+
- No speculative abstractions: do not add options, layers or helpers nobody uses yet.
|
|
52
|
+
- No unused exports, imports or variables.
|
|
53
|
+
- No `console.log`; use `Effect.log`. `console.warn` and `console.error` are allowed.
|
|
54
|
+
- No defensive checks for cases the types already rule out.
|
|
55
|
+
- Do not disable lint rules to get a check passing. Fix the code. Generated files are already ignored.
|
|
56
|
+
|
|
57
|
+
## Commands
|
|
58
|
+
|
|
59
|
+
| Command | Use |
|
|
60
|
+
| -------------------------- | ----------------------------------------------------------------- |
|
|
61
|
+
| `pnpm dev` | Dev server |
|
|
62
|
+
| `pnpm check` | Format check, lint (incl. Effect diagnostics), types |
|
|
63
|
+
| `pnpm format` | Apply formatting (oxfmt via Vite+) |
|
|
64
|
+
| `pnpm lint` | Lint only |
|
|
65
|
+
| `pnpm typecheck` | Regenerate the route tree, then type-check every workspace |
|
|
66
|
+
| `pnpm --filter web routes` | Regenerate `routeTree.gen.ts` after adding or moving a route file |
|
|
67
|
+
| `pnpm test` | Tests (`@effect/vitest`) |
|
|
68
|
+
| `pnpm build` | Build every workspace |
|
|
69
|
+
|
|
70
|
+
Lint and format are configured in the root `vite.config.ts`. The Effect rules need the
|
|
71
|
+
patched install that `pnpm install` performs (`prepare` script); re-run it if they go quiet.
|
|
72
|
+
`routeTree.gen.ts` is not committed: `pnpm install` generates it (`postinstall` in `apps/web`),
|
|
73
|
+
`pnpm dev` and `pnpm build` keep it current, and `pnpm typecheck` regenerates it first, so a fresh
|
|
74
|
+
clone works after `pnpm install`. Run `pnpm --filter web routes` after adding a route file if
|
|
75
|
+
your editor reports a stale route tree.
|
|
76
|
+
|
|
77
|
+
## Before you finish
|
|
78
|
+
|
|
79
|
+
Run `pnpm check && pnpm typecheck && pnpm test && pnpm build` and fix everything it reports.
|
|
80
|
+
Zero errors and zero warnings are the bar.
|
|
81
|
+
|
|
82
|
+
<!-- efforge:agents -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@AGENTS.md
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# My app
|
|
2
|
+
|
|
3
|
+
Effect 4 + TanStack Start on Cloudflare Workers, generated by [efforge](https://github.com/amagdy46/efforge).
|
|
4
|
+
|
|
5
|
+
## Develop
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm dev # http://localhost:5173 (or the port Vite prints)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
With a database, set it up before the first `pnpm dev`: for Postgres, `docker compose up -d --wait`, then `pnpm db:migrate` (Postgres and D1). Anything that queries it, sign-up included, fails until the tables exist. `AGENTS.md` describes the database workflow for this stack.
|
|
13
|
+
|
|
14
|
+
Local secrets live in `.dev.vars` (in `.env` with Alchemy); `.env.example` lists the variables each add-on needs.
|
|
15
|
+
|
|
16
|
+
## Scripts
|
|
17
|
+
|
|
18
|
+
| Command | What it does |
|
|
19
|
+
| ---------------- | -------------------------------- |
|
|
20
|
+
| `pnpm dev` | Start the dev server |
|
|
21
|
+
| `pnpm build` | Build every workspace |
|
|
22
|
+
| `pnpm typecheck` | Type-check every workspace |
|
|
23
|
+
| `pnpm check` | Format check, lint, Effect rules |
|
|
24
|
+
| `pnpm format` | Apply formatting (Vite+ oxfmt) |
|
|
25
|
+
| `pnpm lint` | Lint only (oxlint) |
|
|
26
|
+
| `pnpm test` | Run tests (`@effect/vitest`) |
|
|
27
|
+
|
|
28
|
+
## Layout
|
|
29
|
+
|
|
30
|
+
- `apps/web`: TanStack Start app (routes in `src/routes`, Effect layers in `src/server/layers.ts`)
|
|
31
|
+
- `packages/core`: service interfaces shared across the app
|
|
32
|
+
- `efforge.jsonc`: the choices this project was generated with; `efforge add` reads it
|