create-fate 0.0.0 → 1.0.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 +24 -0
- package/bin/create-fate.mjs +412 -0
- package/package.json +26 -3
- package/templates/fate/README.md +8 -0
- package/templates/fate/drizzle/.github/workflows/push.yml +27 -0
- package/templates/fate/drizzle/.oxfmtrc.jsonc +23 -0
- package/templates/fate/drizzle/.vite-hooks/pre-commit +1 -0
- package/templates/fate/drizzle/.vscode/extensions.json +12 -0
- package/templates/fate/drizzle/.vscode/settings.json +25 -0
- package/templates/fate/drizzle/AGENTS.md +55 -0
- package/templates/fate/drizzle/README.md +112 -0
- package/templates/fate/drizzle/_gitignore +20 -0
- package/templates/fate/drizzle/client/package.json +58 -0
- package/templates/fate/drizzle/client/pages/index.tsx +96 -0
- package/templates/fate/drizzle/client/pages/layout.tsx +104 -0
- package/templates/fate/drizzle/client/pages/login.tsx +107 -0
- package/templates/fate/drizzle/client/pages/post/[id].tsx +22 -0
- package/templates/fate/drizzle/client/pages/search.tsx +95 -0
- package/templates/fate/drizzle/client/public/icon.svg +1 -0
- package/templates/fate/drizzle/client/src/App.css +153 -0
- package/templates/fate/drizzle/client/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/drizzle/client/src/lib/cx.tsx +6 -0
- package/templates/fate/drizzle/client/src/lib/env.tsx +5 -0
- package/templates/fate/drizzle/client/src/ui/Badge.tsx +31 -0
- package/templates/fate/drizzle/client/src/ui/Button.tsx +108 -0
- package/templates/fate/drizzle/client/src/ui/Card.tsx +32 -0
- package/templates/fate/drizzle/client/src/ui/CommentCard.tsx +75 -0
- package/templates/fate/drizzle/client/src/ui/Error.tsx +19 -0
- package/templates/fate/drizzle/client/src/ui/H2.tsx +15 -0
- package/templates/fate/drizzle/client/src/ui/H3.tsx +20 -0
- package/templates/fate/drizzle/client/src/ui/Header.tsx +96 -0
- package/templates/fate/drizzle/client/src/ui/Input.tsx +17 -0
- package/templates/fate/drizzle/client/src/ui/Link.tsx +11 -0
- package/templates/fate/drizzle/client/src/ui/LocaleSwitcher.tsx +52 -0
- package/templates/fate/drizzle/client/src/ui/PostCard.tsx +284 -0
- package/templates/fate/drizzle/client/src/ui/Section.tsx +23 -0
- package/templates/fate/drizzle/client/src/ui/UserCard.tsx +131 -0
- package/templates/fate/drizzle/client/src/user/AuthClient.tsx +6 -0
- package/templates/fate/drizzle/client/translations/de_DE.json +689 -0
- package/templates/fate/drizzle/client/translations/ja_JP.json +689 -0
- package/templates/fate/drizzle/client/vite.config.ts +39 -0
- package/templates/fate/drizzle/client/void.json +29 -0
- package/templates/fate/drizzle/docker-compose.yml +11 -0
- package/templates/fate/drizzle/package.json +46 -0
- package/templates/fate/drizzle/pnpm-workspace.yaml +36 -0
- package/templates/fate/drizzle/public/fate-logo-dark.svg +4 -0
- package/templates/fate/drizzle/public/fate-logo.svg +4 -0
- package/templates/fate/drizzle/server/.env.example +5 -0
- package/templates/fate/drizzle/server/drizzle.config.ts +11 -0
- package/templates/fate/drizzle/server/package.json +48 -0
- package/templates/fate/drizzle/server/src/__tests__/index.test.tsx +5 -0
- package/templates/fate/drizzle/server/src/app.tsx +44 -0
- package/templates/fate/drizzle/server/src/drizzle/db.ts +25 -0
- package/templates/fate/drizzle/server/src/drizzle/queries.ts +89 -0
- package/templates/fate/drizzle/server/src/drizzle/schema.ts +174 -0
- package/templates/fate/drizzle/server/src/drizzle/seed.tsx +77 -0
- package/templates/fate/drizzle/server/src/drizzle/seedData.ts +205 -0
- package/templates/fate/drizzle/server/src/index.tsx +24 -0
- package/templates/fate/drizzle/server/src/lib/auth.ts +33 -0
- package/templates/fate/drizzle/server/src/lib/env.ts +3 -0
- package/templates/fate/drizzle/server/src/lib/origins.ts +18 -0
- package/templates/fate/drizzle/server/src/router.ts +15 -0
- package/templates/fate/drizzle/server/src/trpc/connection.ts +4 -0
- package/templates/fate/drizzle/server/src/trpc/context.ts +22 -0
- package/templates/fate/drizzle/server/src/trpc/init.ts +51 -0
- package/templates/fate/drizzle/server/src/trpc/routers/comment.ts +146 -0
- package/templates/fate/drizzle/server/src/trpc/routers/post.ts +99 -0
- package/templates/fate/drizzle/server/src/trpc/routers/user.ts +68 -0
- package/templates/fate/drizzle/server/src/trpc/views.ts +75 -0
- package/templates/fate/drizzle/server/src/user/SessionUser.tsx +17 -0
- package/templates/fate/drizzle/server/vite.config.ts +8 -0
- package/templates/fate/drizzle/tsconfig.json +33 -0
- package/templates/fate/drizzle/vite.config.ts +71 -0
- package/templates/fate/http/.github/workflows/push.yml +27 -0
- package/templates/fate/http/.oxfmtrc.jsonc +23 -0
- package/templates/fate/http/.vite-hooks/pre-commit +1 -0
- package/templates/fate/http/.vscode/extensions.json +12 -0
- package/templates/fate/http/.vscode/settings.json +25 -0
- package/templates/fate/http/AGENTS.md +55 -0
- package/templates/fate/http/README.md +112 -0
- package/templates/fate/http/_gitignore +20 -0
- package/templates/fate/http/client/package.json +56 -0
- package/templates/fate/http/client/pages/index.tsx +96 -0
- package/templates/fate/http/client/pages/layout.tsx +89 -0
- package/templates/fate/http/client/pages/login.tsx +107 -0
- package/templates/fate/http/client/pages/post/[id].tsx +22 -0
- package/templates/fate/http/client/pages/search.tsx +95 -0
- package/templates/fate/http/client/public/icon.svg +1 -0
- package/templates/fate/http/client/src/App.css +153 -0
- package/templates/fate/http/client/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/http/client/src/lib/cx.tsx +6 -0
- package/templates/fate/http/client/src/lib/env.tsx +5 -0
- package/templates/fate/http/client/src/ui/Badge.tsx +31 -0
- package/templates/fate/http/client/src/ui/Button.tsx +108 -0
- package/templates/fate/http/client/src/ui/Card.tsx +32 -0
- package/templates/fate/http/client/src/ui/CommentCard.tsx +75 -0
- package/templates/fate/http/client/src/ui/Error.tsx +19 -0
- package/templates/fate/http/client/src/ui/H2.tsx +15 -0
- package/templates/fate/http/client/src/ui/H3.tsx +20 -0
- package/templates/fate/http/client/src/ui/Header.tsx +96 -0
- package/templates/fate/http/client/src/ui/Input.tsx +17 -0
- package/templates/fate/http/client/src/ui/Link.tsx +11 -0
- package/templates/fate/http/client/src/ui/LocaleSwitcher.tsx +52 -0
- package/templates/fate/http/client/src/ui/PostCard.tsx +281 -0
- package/templates/fate/http/client/src/ui/Section.tsx +23 -0
- package/templates/fate/http/client/src/ui/UserCard.tsx +131 -0
- package/templates/fate/http/client/src/user/AuthClient.tsx +6 -0
- package/templates/fate/http/client/translations/de_DE.json +689 -0
- package/templates/fate/http/client/translations/ja_JP.json +689 -0
- package/templates/fate/http/client/vite.config.ts +40 -0
- package/templates/fate/http/client/void.json +29 -0
- package/templates/fate/http/docker-compose.yml +11 -0
- package/templates/fate/http/package.json +46 -0
- package/templates/fate/http/pnpm-workspace.yaml +36 -0
- package/templates/fate/http/public/fate-logo-dark.svg +4 -0
- package/templates/fate/http/public/fate-logo.svg +4 -0
- package/templates/fate/http/server/.env.example +5 -0
- package/templates/fate/http/server/drizzle.config.ts +11 -0
- package/templates/fate/http/server/package.json +46 -0
- package/templates/fate/http/server/src/__tests__/index.test.tsx +5 -0
- package/templates/fate/http/server/src/app.tsx +36 -0
- package/templates/fate/http/server/src/drizzle/db.ts +25 -0
- package/templates/fate/http/server/src/drizzle/queries.ts +89 -0
- package/templates/fate/http/server/src/drizzle/schema.ts +174 -0
- package/templates/fate/http/server/src/drizzle/seed.tsx +77 -0
- package/templates/fate/http/server/src/drizzle/seedData.ts +205 -0
- package/templates/fate/http/server/src/fate/context.ts +20 -0
- package/templates/fate/http/server/src/fate/server.ts +285 -0
- package/templates/fate/http/server/src/fate/views.ts +75 -0
- package/templates/fate/http/server/src/index.tsx +24 -0
- package/templates/fate/http/server/src/lib/auth.ts +33 -0
- package/templates/fate/http/server/src/lib/env.ts +3 -0
- package/templates/fate/http/server/src/lib/origins.ts +18 -0
- package/templates/fate/http/server/src/router.ts +2 -0
- package/templates/fate/http/server/src/user/SessionUser.tsx +17 -0
- package/templates/fate/http/server/vite.config.ts +8 -0
- package/templates/fate/http/tsconfig.json +33 -0
- package/templates/fate/http/vite.config.ts +71 -0
- package/templates/fate/prisma/.github/workflows/push.yml +27 -0
- package/templates/fate/prisma/.oxfmtrc.jsonc +23 -0
- package/templates/fate/prisma/.vite-hooks/pre-commit +1 -0
- package/templates/fate/prisma/.vscode/extensions.json +12 -0
- package/templates/fate/prisma/.vscode/settings.json +25 -0
- package/templates/fate/prisma/AGENTS.md +55 -0
- package/templates/fate/prisma/README.md +126 -0
- package/templates/fate/prisma/_gitignore +20 -0
- package/templates/fate/prisma/client/package.json +58 -0
- package/templates/fate/prisma/client/pages/index.tsx +96 -0
- package/templates/fate/prisma/client/pages/layout.tsx +94 -0
- package/templates/fate/prisma/client/pages/login.tsx +107 -0
- package/templates/fate/prisma/client/pages/post/[id].tsx +22 -0
- package/templates/fate/prisma/client/pages/search.tsx +95 -0
- package/templates/fate/prisma/client/public/icon.svg +1 -0
- package/templates/fate/prisma/client/src/App.css +153 -0
- package/templates/fate/prisma/client/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/prisma/client/src/lib/cx.tsx +6 -0
- package/templates/fate/prisma/client/src/lib/env.tsx +5 -0
- package/templates/fate/prisma/client/src/ui/Badge.tsx +31 -0
- package/templates/fate/prisma/client/src/ui/Button.tsx +108 -0
- package/templates/fate/prisma/client/src/ui/Card.tsx +32 -0
- package/templates/fate/prisma/client/src/ui/CommentCard.tsx +75 -0
- package/templates/fate/prisma/client/src/ui/Error.tsx +19 -0
- package/templates/fate/prisma/client/src/ui/H2.tsx +15 -0
- package/templates/fate/prisma/client/src/ui/H3.tsx +20 -0
- package/templates/fate/prisma/client/src/ui/Header.tsx +96 -0
- package/templates/fate/prisma/client/src/ui/Input.tsx +17 -0
- package/templates/fate/prisma/client/src/ui/Link.tsx +11 -0
- package/templates/fate/prisma/client/src/ui/LocaleSwitcher.tsx +52 -0
- package/templates/fate/prisma/client/src/ui/PostCard.tsx +281 -0
- package/templates/fate/prisma/client/src/ui/Section.tsx +23 -0
- package/templates/fate/prisma/client/src/ui/UserCard.tsx +131 -0
- package/templates/fate/prisma/client/src/user/AuthClient.tsx +6 -0
- package/templates/fate/prisma/client/translations/de_DE.json +689 -0
- package/templates/fate/prisma/client/translations/ja_JP.json +689 -0
- package/templates/fate/prisma/client/vite.config.ts +39 -0
- package/templates/fate/prisma/client/void.json +29 -0
- package/templates/fate/prisma/docker-compose.yml +11 -0
- package/templates/fate/prisma/package.json +47 -0
- package/templates/fate/prisma/pnpm-workspace.yaml +39 -0
- package/templates/fate/prisma/public/fate-logo-dark.svg +4 -0
- package/templates/fate/prisma/public/fate-logo.svg +4 -0
- package/templates/fate/prisma/server/.env.example +5 -0
- package/templates/fate/prisma/server/package.json +42 -0
- package/templates/fate/prisma/server/prisma.config.ts +21 -0
- package/templates/fate/prisma/server/src/__tests__/index.test.tsx +5 -0
- package/templates/fate/prisma/server/src/app.tsx +40 -0
- package/templates/fate/prisma/server/src/index.tsx +24 -0
- package/templates/fate/prisma/server/src/lib/auth.ts +31 -0
- package/templates/fate/prisma/server/src/lib/env.ts +3 -0
- package/templates/fate/prisma/server/src/lib/origins.ts +18 -0
- package/templates/fate/prisma/server/src/prisma/prisma.ts +9 -0
- package/templates/fate/prisma/server/src/prisma/schema.prisma +98 -0
- package/templates/fate/prisma/server/src/prisma/seed.tsx +71 -0
- package/templates/fate/prisma/server/src/prisma/seedData.ts +205 -0
- package/templates/fate/prisma/server/src/router.ts +14 -0
- package/templates/fate/prisma/server/src/trpc/connection.ts +4 -0
- package/templates/fate/prisma/server/src/trpc/context.ts +22 -0
- package/templates/fate/prisma/server/src/trpc/init.ts +8 -0
- package/templates/fate/prisma/server/src/trpc/routers/comment.ts +176 -0
- package/templates/fate/prisma/server/src/trpc/routers/post.ts +154 -0
- package/templates/fate/prisma/server/src/trpc/routers/user.ts +71 -0
- package/templates/fate/prisma/server/src/trpc/views.ts +77 -0
- package/templates/fate/prisma/server/src/user/SessionUser.tsx +17 -0
- package/templates/fate/prisma/server/vite.config.ts +8 -0
- package/templates/fate/prisma/tsconfig.json +33 -0
- package/templates/fate/prisma/vite.config.ts +72 -0
- package/templates/fate/void/.oxfmtrc.jsonc +14 -0
- package/templates/fate/void/README.md +55 -0
- package/templates/fate/void/auth.ts +22 -0
- package/templates/fate/void/db/migrations/20260508073357_initial_schema.sql +133 -0
- package/templates/fate/void/db/migrations/20260508120500_seed_void_demo.sql +170 -0
- package/templates/fate/void/db/migrations/meta/20260508073357_snapshot.json +868 -0
- package/templates/fate/void/db/migrations/meta/_journal.json +20 -0
- package/templates/fate/void/db/queries.ts +211 -0
- package/templates/fate/void/db/schema.ts +325 -0
- package/templates/fate/void/db/seed-auth.ts +31 -0
- package/templates/fate/void/db/seed.ts +163 -0
- package/templates/fate/void/middleware/01.shared.ts +29 -0
- package/templates/fate/void/package.json +65 -0
- package/templates/fate/void/pages/category/[id].tsx +23 -0
- package/templates/fate/void/pages/index.tsx +153 -0
- package/templates/fate/void/pages/layout.tsx +46 -0
- package/templates/fate/void/pages/login.tsx +103 -0
- package/templates/fate/void/pages/post/[id].tsx +20 -0
- package/templates/fate/void/pages/search.tsx +81 -0
- package/templates/fate/void/pnpm-workspace.yaml +31 -0
- package/templates/fate/void/public/.assetsignore +1 -0
- package/templates/fate/void/public/icon.svg +1 -0
- package/templates/fate/void/routes/fate-live.ts +8 -0
- package/templates/fate/void/routes/fate.ts +8 -0
- package/templates/fate/void/seedData.ts +535 -0
- package/templates/fate/void/src/App.css +130 -0
- package/templates/fate/void/src/fate/__tests__/commentPermissions.test.ts +31 -0
- package/templates/fate/void/src/fate/commentPermissions.ts +17 -0
- package/templates/fate/void/src/fate/context.ts +15 -0
- package/templates/fate/void/src/fate/live.ts +6 -0
- package/templates/fate/void/src/fate/server.ts +401 -0
- package/templates/fate/void/src/fate/views.ts +164 -0
- package/templates/fate/void/src/lib/cx.tsx +6 -0
- package/templates/fate/void/src/lib/formatLabel.tsx +6 -0
- package/templates/fate/void/src/lib/shared.ts +10 -0
- package/templates/fate/void/src/ui/Badge.tsx +31 -0
- package/templates/fate/void/src/ui/Button.tsx +92 -0
- package/templates/fate/void/src/ui/Card.tsx +29 -0
- package/templates/fate/void/src/ui/CategoryCard.tsx +105 -0
- package/templates/fate/void/src/ui/CommentCard.tsx +80 -0
- package/templates/fate/void/src/ui/CreatePost.tsx +111 -0
- package/templates/fate/void/src/ui/Error.tsx +19 -0
- package/templates/fate/void/src/ui/EventCard.tsx +152 -0
- package/templates/fate/void/src/ui/H2.tsx +15 -0
- package/templates/fate/void/src/ui/H3.tsx +20 -0
- package/templates/fate/void/src/ui/Header.tsx +96 -0
- package/templates/fate/void/src/ui/Input.tsx +33 -0
- package/templates/fate/void/src/ui/Link.tsx +11 -0
- package/templates/fate/void/src/ui/Number.tsx +5 -0
- package/templates/fate/void/src/ui/PostCard.tsx +294 -0
- package/templates/fate/void/src/ui/Section.tsx +23 -0
- package/templates/fate/void/src/ui/TagBadge.tsx +23 -0
- package/templates/fate/void/src/ui/UserCard.tsx +129 -0
- package/templates/fate/void/src/user/AuthClient.tsx +1 -0
- package/templates/fate/void/src/user/SessionUser.tsx +17 -0
- package/templates/fate/void/tsconfig.json +34 -0
- package/templates/fate/void/vite.config.ts +83 -0
- package/templates/fate/void/void.json +32 -0
- package/templates/fate/void/wrangler.jsonc +16 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowImportingTsExtensions": true,
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"incremental": true,
|
|
8
|
+
"isolatedModules": true,
|
|
9
|
+
"jsx": "react-jsx",
|
|
10
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
11
|
+
"module": "nodenext",
|
|
12
|
+
"moduleResolution": "nodenext",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"noImplicitOverride": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"target": "es2017",
|
|
20
|
+
"types": ["vite/client"]
|
|
21
|
+
},
|
|
22
|
+
"exclude": ["**/.void/**/*.ts", "node_modules"],
|
|
23
|
+
"include": ["**/.fate/*.ts", "**/*.ts", "**/*.tsx"],
|
|
24
|
+
"ts-node": {
|
|
25
|
+
"transpileOnly": true,
|
|
26
|
+
"transpiler": "ts-node/transpilers/swc",
|
|
27
|
+
"files": true,
|
|
28
|
+
"compilerOptions": {
|
|
29
|
+
"module": "esnext",
|
|
30
|
+
"isolatedModules": false
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import nkzw from '@nkzw/oxlint-config';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
import { defineConfig } from 'vite-plus';
|
|
5
|
+
|
|
6
|
+
const root = process.cwd();
|
|
7
|
+
|
|
8
|
+
dotenv.config({
|
|
9
|
+
path: join(root, './server', '.env'),
|
|
10
|
+
quiet: true,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
fmt: {
|
|
15
|
+
experimentalSortImports: {
|
|
16
|
+
newlinesBetween: false,
|
|
17
|
+
},
|
|
18
|
+
experimentalSortPackageJson: {
|
|
19
|
+
sortScripts: true,
|
|
20
|
+
},
|
|
21
|
+
experimentalTailwindcss: {
|
|
22
|
+
stylesheet: 'client/src/App.css',
|
|
23
|
+
},
|
|
24
|
+
ignorePatterns: [
|
|
25
|
+
'coverage/',
|
|
26
|
+
'dist/',
|
|
27
|
+
'.fate/',
|
|
28
|
+
'client/dist/',
|
|
29
|
+
'client/src/translations/',
|
|
30
|
+
'server/dist/',
|
|
31
|
+
'pnpm-lock.yaml',
|
|
32
|
+
],
|
|
33
|
+
singleQuote: true,
|
|
34
|
+
},
|
|
35
|
+
lint: {
|
|
36
|
+
extends: [nkzw],
|
|
37
|
+
ignorePatterns: [
|
|
38
|
+
'coverage',
|
|
39
|
+
'dist',
|
|
40
|
+
'.fate',
|
|
41
|
+
'client/dist',
|
|
42
|
+
'server/dist',
|
|
43
|
+
'server/src/drizzle/migrations/**',
|
|
44
|
+
'vite.config.ts.timestamp-*',
|
|
45
|
+
'client/vite.config.ts.timestamp-*',
|
|
46
|
+
'server/vite.config.ts.timestamp-*',
|
|
47
|
+
],
|
|
48
|
+
options: { typeAware: true, typeCheck: true },
|
|
49
|
+
overrides: [
|
|
50
|
+
{
|
|
51
|
+
files: ['server/src/index.tsx', 'server/src/drizzle/seed.tsx', '**/__tests__/**'],
|
|
52
|
+
rules: {
|
|
53
|
+
'no-console': 'off',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
rules: {
|
|
58
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
run: {
|
|
62
|
+
tasks: {
|
|
63
|
+
'test:all': {
|
|
64
|
+
command: 'vp check && vp test',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
staged: {
|
|
69
|
+
'*': 'vp check --fix',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [24]
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: voidzero-dev/setup-vp@v1
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
cache: true
|
|
23
|
+
run-install: true
|
|
24
|
+
- run: |
|
|
25
|
+
vp run dev:setup
|
|
26
|
+
vp run test:all
|
|
27
|
+
vp run build
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"experimentalSortImports": {
|
|
5
|
+
"newlinesBetween": false,
|
|
6
|
+
},
|
|
7
|
+
"experimentalSortPackageJson": {
|
|
8
|
+
"sortScripts": true,
|
|
9
|
+
},
|
|
10
|
+
"experimentalTailwindcss": {
|
|
11
|
+
"stylesheet": "client/src/App.css",
|
|
12
|
+
},
|
|
13
|
+
"ignorePatterns": [
|
|
14
|
+
"client/dist/",
|
|
15
|
+
"client/index.html",
|
|
16
|
+
"client/src/fate.ts",
|
|
17
|
+
"client/src/translations/",
|
|
18
|
+
"coverage/",
|
|
19
|
+
"dist/",
|
|
20
|
+
"pnpm-lock.yaml",
|
|
21
|
+
"server/dist",
|
|
22
|
+
],
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
vp staged
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"recommendations": [
|
|
3
|
+
"dbaeumer.vscode-eslint",
|
|
4
|
+
"oxc.oxc-vscode",
|
|
5
|
+
"styled-components.vscode-styled-components",
|
|
6
|
+
"sysoev.vscode-open-in-github",
|
|
7
|
+
"tailwindcss.intellisense",
|
|
8
|
+
"TypeScriptTeam.native-preview",
|
|
9
|
+
"usernamehw.errorlens",
|
|
10
|
+
"wix.vscode-import-cost"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"files.insertFinalNewline": true,
|
|
4
|
+
"files.trimFinalNewlines": true,
|
|
5
|
+
"editor.codeActionsOnSave": {
|
|
6
|
+
"source.fixAll.eslint": "explicit"
|
|
7
|
+
},
|
|
8
|
+
"[javascript]": {
|
|
9
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
10
|
+
},
|
|
11
|
+
"[typescriptreact]": {
|
|
12
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
13
|
+
},
|
|
14
|
+
"[typescript]": {
|
|
15
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
16
|
+
},
|
|
17
|
+
"[json]": {
|
|
18
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
19
|
+
},
|
|
20
|
+
"typescript.preferences.importModuleSpecifierEnding": "js",
|
|
21
|
+
"typescript.reportStyleChecksAsWarnings": false,
|
|
22
|
+
"typescript.updateImportsOnFileMove.enabled": "always",
|
|
23
|
+
"typescript.preferences.autoImportFileExcludePatterns": ["**/node_modules/vitest"],
|
|
24
|
+
"typescript.experimental.useTsgo": true
|
|
25
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Using _fate_ for React applications
|
|
2
|
+
|
|
3
|
+
This guidance is for agents working in projects bootstrapped from the fate template. It focuses on the client-side patterns for fate's view composition and action execution.
|
|
4
|
+
|
|
5
|
+
## Core Workflow
|
|
6
|
+
|
|
7
|
+
- **Define views with explicit selections:** Define reusable view objects with `view<T>()({...})`, compose them via spreads, and resolve them with `useView`.
|
|
8
|
+
- **Resolve data via references:** Avoid passing raw fetched objects; instead pass `ViewRef`s to downstream components to keep selections scoped and cache-aware. Then call `const result = useView(viewDefinition, ref)` to read only the selected fields while subscribing to cache updates. Name the prop after the result data, and rename it using destructuring in the function arguments: `const PostComponent = ({ post: postRef }: { post: ViewRef<'Post'>}) => { const post = useView(PostView, postRef); ... }`.
|
|
9
|
+
- **Request data at screen roots:** Use `useRequest` to compose all views required for a route or screen into a single typed request; wrap roots in `Suspense` and an error boundary since requests may suspend or throw.
|
|
10
|
+
- **Compose reusable views:** Extract nested selections into their own views (e.g., `UserView`) and compose them inside parent views (`author: UserView`) to avoid duplication and overfetching. This keeps selections DRY and ensures view updates propagate consistently when the cache changes.
|
|
11
|
+
|
|
12
|
+
## Actions & Mutations
|
|
13
|
+
|
|
14
|
+
- **Prefer `fate.actions` with `useActionState`:** Trigger mutations through React Actions to integrate with Suspense/`useTransition`, receiving `[result, action, isPending]`. Call actions via the relevant data inputs, for example `action({input: { id: post.id }})`.
|
|
15
|
+
- **Optimistic updates by default:** Pass `optimistic` payloads to immediately update the normalized cache; only views selecting the changed fields re-render and failures roll back automatically. Optimistic payloads should match the expected server data changes of the associated object.
|
|
16
|
+
- **Select extra fields when side effects matter:** When a mutation affects related entities (e.g., comment count on a post), pass a `view` to the action to fetch the needed fields in the same round-trip and keep the cache coherent for all dependent views.
|
|
17
|
+
- **Imperative escape hatch:** Use `fate.mutations` when you must fire mutations outside React components or without waiting on prior actions; handle loading/error states yourself.
|
|
18
|
+
- **Handle deletions and resets explicitly:** Use the `delete: true` flag to evict records from the cache, and send the `'reset'` token to clear stale action errors without re-running the mutation.
|
|
19
|
+
- **Error handling model:** Treat expected errors (e.g., 404) at the call site via the action result; unexpected errors bubble to the nearest React error boundary.
|
|
20
|
+
|
|
21
|
+
## Common Pitfalls
|
|
22
|
+
|
|
23
|
+
- **Use ViewRefs:** Pass references instead of raw data. Keep components focused on views and `ViewRef`s to let fate manage data masking and updates.
|
|
24
|
+
- **Co-locate data needs:** Keep view definitions near their components and compose them upward to the request root for predictable fetching.
|
|
25
|
+
- **Use Suspense:** Wrap pages in `Suspense`/`ErrorBoundary` instead of ad-hoc loading/error flags; fate aligns with Async React by design.
|
|
26
|
+
- **Do not duplicate types:** Keep generated tRPC types and views imported from the server package. Avoid redefining entity shapes on the client. This ensures view selections stay type-safe end-to-end.
|
|
27
|
+
- **`useRequest` only at the root:** When adding routes or layouts, create a dedicated `useRequest` call per screen root that pulls together all child views; do not scatter `useRequest` across leaf components unless it's necessary to issue requests due to user input.
|
|
28
|
+
- **React Actions:** Prefer React Action-friendly UI primitives (buttons/forms that accept an `action` prop). If unavailable, wrap action calls with `startTransition` in `onClick` handlers.
|
|
29
|
+
- **Generated Client** The fate client is generated via `pnpm fate:generate`. It should not be manually edited. Instead make the proper schema changes on the server and run `pnpm fate:generate`.
|
|
30
|
+
- **Library Versions:** This repository uses the most recent releases of React, fate, Vite, tRPC, and more. You might not know about the new releases yet, please don't get confused. The versions you see are real, and there are no feature or version mismatches. You can search the internet for more information about them.
|
|
31
|
+
|
|
32
|
+
Full documentation can be found on the filesystem at `./client/node_modules/react-fate/README.md` or online at [fate.technology](https://fate.technology/).
|
|
33
|
+
|
|
34
|
+
## Review Checklist for Agents
|
|
35
|
+
|
|
36
|
+
- [ ] Every component that reads server data does so through `useView` and receives a `ViewRef` prop.
|
|
37
|
+
- [ ] Root components gather data with a single `useRequest` call.
|
|
38
|
+
- [ ] Mutations are wired through `useActionState` with optimistic updates and necessary `view` selections; imperative `fate.mutations` are justified when used.
|
|
39
|
+
- [ ] Shared selections live in reusable views using regular JavaScript object spreads rather than duplicated field lists.
|
|
40
|
+
|
|
41
|
+
<!--VITE PLUS START-->
|
|
42
|
+
|
|
43
|
+
# Using Vite+, the Unified Toolchain for the Web
|
|
44
|
+
|
|
45
|
+
This project is using Vite+, a unified toolchain built on top of Vite, Rolldown, Vitest, tsdown, Oxlint, Oxfmt, and Vite Task. Vite+ wraps runtime management, package management, and frontend tooling in a single global CLI called `vp`. Vite+ is distinct from Vite, and it invokes Vite through `vp dev` and `vp build`. Run `vp help` to print a list of commands and `vp <command> --help` for information about a specific command.
|
|
46
|
+
|
|
47
|
+
Docs are local at `node_modules/vite-plus/docs` or online at https://viteplus.dev/guide/.
|
|
48
|
+
|
|
49
|
+
## Review Checklist
|
|
50
|
+
|
|
51
|
+
- [ ] Run `vp install` after pulling remote changes and before getting started.
|
|
52
|
+
- [ ] Run `vp check` and `vp test` to format, lint, type check and test changes.
|
|
53
|
+
- [ ] Check if there are `vite.config.ts` tasks or `package.json` scripts necessary for validation, run via `vp run <script>`.
|
|
54
|
+
|
|
55
|
+
<!--VITE PLUS END-->
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="/public/fate-logo-dark.svg">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="/public/fate-logo.svg">
|
|
5
|
+
<img alt="Logo" src="/public/fate-logo.svg" width="50%">
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
**_fate_** is a modern data client for React inspired by [Relay](https://relay.dev/) and [GraphQL](https://graphql.org/). It combines view composition, normalized caching, data masking, Async React features, and type-safe data fetching.
|
|
10
|
+
|
|
11
|
+
Check out [fate.technology](https://fate.technology) for documentation, examples, and guides.
|
|
12
|
+
|
|
13
|
+
# _fate_ Quick Start Template
|
|
14
|
+
|
|
15
|
+
Create a new fate app with Vite+:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
vp create fate my-app --template prisma
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Getting Started with _fate_
|
|
22
|
+
|
|
23
|
+
Read the [Getting Started Guide](https://fate.technology/guide/core-concepts) to learn how to use _fate_ in your React applications.
|
|
24
|
+
|
|
25
|
+
## Technologies
|
|
26
|
+
|
|
27
|
+
This default template combines the Nakazawa Tech's [Web App Template](https://github.com/nkzw-tech/web-app-template) and [Server Template](https://github.com/nkzw-tech/server-template) into a monorepo, with unified tooling and _fate_ as the data client. It currently uses tRPC with Prisma.
|
|
28
|
+
|
|
29
|
+
_This template lives on the edge._ It's a turbocharged starting point on top of an already optimized stack. It uses TypeScript Go, Vite+, and ships with sensible defaults to unlock an incredibly fast development experience. It follows the principles laid out in [Building Scalable Applications](https://www.youtube.com/watch?v=rxPTEko8J7c&t=36s).
|
|
30
|
+
|
|
31
|
+
Next to [_fate_](https://fate.technology), it comes with the following technologies:
|
|
32
|
+
|
|
33
|
+
### Client Technologies
|
|
34
|
+
|
|
35
|
+
- [Vite 8](https://vitejs.dev/)
|
|
36
|
+
- [React](https://reactjs.org/) with [React Compiler](https://react.dev/learn/react-compiler) enabled
|
|
37
|
+
- [Tailwind](https://tailwindcss.com/)
|
|
38
|
+
- [fbtee](https://github.com/nkzw-tech/fbtee) for i18n
|
|
39
|
+
- [Better Auth](https://www.better-auth.com/) for authentication
|
|
40
|
+
- [Void Pages Router](https://void.cloud/docs)
|
|
41
|
+
- [TypeScript](https://www.typescriptlang.org)
|
|
42
|
+
- [pnpm](https://pnpm.io/)
|
|
43
|
+
|
|
44
|
+
### Server Technologies
|
|
45
|
+
|
|
46
|
+
- [Prisma](https://www.prisma.io/) as the ORM, with the new ESM multi-file generated client.
|
|
47
|
+
- [tRPC](https://trpc.io/) for type-safe APIs.
|
|
48
|
+
- [Hono](https://hono.dev/)
|
|
49
|
+
- [Better Auth](https://better-auth.com/) for Authentication.
|
|
50
|
+
|
|
51
|
+
### Folder Structure
|
|
52
|
+
|
|
53
|
+
- `client/` - The React client application using _fate_.
|
|
54
|
+
- `server/` - The fate server using tRPC with Prisma.
|
|
55
|
+
|
|
56
|
+
## Initial Setup
|
|
57
|
+
|
|
58
|
+
You'll need Node.js 24+ and [Vite+](https://viteplus.dev/guide/).
|
|
59
|
+
|
|
60
|
+
Install dependencies:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
vp install
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Review `server/.env`, which is copied from `server/.env.example` when the app is created. The default local values expect:
|
|
67
|
+
|
|
68
|
+
- Postgres at `postgresql://fate:echo@localhost:5432/fate`.
|
|
69
|
+
- The server at `http://localhost:9000`.
|
|
70
|
+
- The client at `http://localhost:5173`.
|
|
71
|
+
|
|
72
|
+
Start Postgres with Docker:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
docker-compose up -d
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Alternatively, create the database manually:
|
|
79
|
+
|
|
80
|
+
```SQL
|
|
81
|
+
CREATE ROLE fate WITH LOGIN PASSWORD 'echo';
|
|
82
|
+
CREATE DATABASE fate;
|
|
83
|
+
ALTER DATABASE fate OWNER TO fate;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For local development, push the Prisma schema and seed the database:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
vp run prisma db push
|
|
90
|
+
vp run prisma db seed
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
If you prefer migration files, use Prisma's migration workflow instead:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
vp run prisma migrate dev --name init
|
|
97
|
+
vp run prisma db seed
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then generate local files:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
vp run dev:setup
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Start the app:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
vp run dev
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The client runs at `http://localhost:5173` and the server runs at `http://localhost:9000`. tRPC requests go to `/trpc`.
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
Common commands from the project root:
|
|
117
|
+
|
|
118
|
+
- `vp run dev` starts the client and server together.
|
|
119
|
+
- `vp run dev:client` starts only the client.
|
|
120
|
+
- `vp run dev:server` starts only the server.
|
|
121
|
+
- `vp run dev:setup` generates the Prisma client, runs fbtee setup, and regenerates the fate client.
|
|
122
|
+
- `vp run fate:generate` regenerates `client/.fate/client.generated.ts` after changing server views, roots, or routers.
|
|
123
|
+
- `vp run prisma` runs Prisma CLI commands in the server package.
|
|
124
|
+
- `vp check --fix` formats, lints, and type-checks the workspace.
|
|
125
|
+
- `vp test` runs the test suite.
|
|
126
|
+
- `vp run build` builds the client and server.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.fate/
|
|
2
|
+
**/.fate/
|
|
3
|
+
.void/
|
|
4
|
+
**/.void/
|
|
5
|
+
.eslintcache
|
|
6
|
+
.pnpm-debug.log
|
|
7
|
+
**/node_modules/
|
|
8
|
+
/node_modules/
|
|
9
|
+
client/.enum_manifest.json
|
|
10
|
+
client/dist/
|
|
11
|
+
client/source_strings.json
|
|
12
|
+
client/src/translations/
|
|
13
|
+
coverage/
|
|
14
|
+
dist/
|
|
15
|
+
server/.env
|
|
16
|
+
server/.prod.env
|
|
17
|
+
server/dist/
|
|
18
|
+
server/src/prisma/prisma-client/
|
|
19
|
+
tsconfig.tsbuildinfo
|
|
20
|
+
vite.config.ts.timestamp-*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@app/client",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"author": "Christoph Nakazawa <christoph.pojer@gmail.com>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git://github.com/nkzw-tech/fate.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "vp build",
|
|
13
|
+
"dev": "vp dev",
|
|
14
|
+
"dev:setup": "vp run fbtee:all",
|
|
15
|
+
"fate:generate": "vp exec fate generate",
|
|
16
|
+
"fbtee:all": "vpx fbtee collect && vpx fbtee translate"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@app/server": "workspace:*",
|
|
20
|
+
"@hono/node-server": "^2.0.1",
|
|
21
|
+
"@nkzw/core": "^1.3.1",
|
|
22
|
+
"@nkzw/define-env": "^1.1.0",
|
|
23
|
+
"@nkzw/stack": "^2.3.2",
|
|
24
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
25
|
+
"@trpc/client": "^11.17.0",
|
|
26
|
+
"@void/react": "^0.7.5",
|
|
27
|
+
"better-auth": "^1.6.9",
|
|
28
|
+
"class-variance-authority": "^0.7.1",
|
|
29
|
+
"clsx": "^2.1.1",
|
|
30
|
+
"fbtee": "^1.7.4",
|
|
31
|
+
"lucide-react": "^1.14.0",
|
|
32
|
+
"react": "^19.2.5",
|
|
33
|
+
"react-dom": "^19.2.5",
|
|
34
|
+
"react-error-boundary": "^6.1.1",
|
|
35
|
+
"react-fate": "latest",
|
|
36
|
+
"tailwind-merge": "^3.5.0",
|
|
37
|
+
"void": "^0.7.5"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@nkzw/babel-preset-fbtee": "^1.7.4",
|
|
41
|
+
"@rolldown/plugin-babel": "^0.2.3",
|
|
42
|
+
"@tailwindcss/vite": "^4.2.4",
|
|
43
|
+
"@trpc/server": "^11.17.0",
|
|
44
|
+
"@types/babel__core": "^7.20.5",
|
|
45
|
+
"@types/node": "^25.6.0",
|
|
46
|
+
"@types/react": "^19.2.14",
|
|
47
|
+
"@types/react-dom": "^19.2.3",
|
|
48
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
49
|
+
"tailwindcss": "^4.2.4",
|
|
50
|
+
"vite": "catalog:",
|
|
51
|
+
"vite-plus": "catalog:"
|
|
52
|
+
},
|
|
53
|
+
"browserslist": [
|
|
54
|
+
">0.2%",
|
|
55
|
+
"not dead",
|
|
56
|
+
"not op_mini all"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import Stack, { VStack } from '@nkzw/stack';
|
|
2
|
+
import { ConnectionRef, useListView, useRequest } from 'react-fate';
|
|
3
|
+
import cx from '../src/lib/cx.tsx';
|
|
4
|
+
import { Button } from '../src/ui/Button.tsx';
|
|
5
|
+
import Card from '../src/ui/Card.tsx';
|
|
6
|
+
import H2 from '../src/ui/H2.tsx';
|
|
7
|
+
import Link from '../src/ui/Link.tsx';
|
|
8
|
+
import { PostCard, PostView } from '../src/ui/PostCard.tsx';
|
|
9
|
+
import Section from '../src/ui/Section.tsx';
|
|
10
|
+
import UserCard, { UserView } from '../src/ui/UserCard.tsx';
|
|
11
|
+
|
|
12
|
+
const PostConnectionView = {
|
|
13
|
+
args: { first: 3 },
|
|
14
|
+
items: {
|
|
15
|
+
node: PostView,
|
|
16
|
+
},
|
|
17
|
+
pagination: {
|
|
18
|
+
hasNext: true,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const PostFeed = ({ posts: postsRef }: { posts: ConnectionRef<'Post'> }) => {
|
|
23
|
+
const [posts, loadNext] = useListView(PostConnectionView, postsRef);
|
|
24
|
+
|
|
25
|
+
return posts.length ? (
|
|
26
|
+
<VStack gap={16}>
|
|
27
|
+
<H2 className="pl-5">
|
|
28
|
+
<fbt desc="Latest posts header">Latest posts</fbt>
|
|
29
|
+
</H2>
|
|
30
|
+
<VStack gap={32}>
|
|
31
|
+
{posts.map(({ node }) => (
|
|
32
|
+
<PostCard key={node.id} post={node} />
|
|
33
|
+
))}
|
|
34
|
+
{loadNext ? (
|
|
35
|
+
<Stack center>
|
|
36
|
+
<Button onClick={loadNext} variant="ghost">
|
|
37
|
+
<fbt desc="Load more posts button">Load more posts</fbt>
|
|
38
|
+
</Button>
|
|
39
|
+
</Stack>
|
|
40
|
+
) : null}
|
|
41
|
+
</VStack>
|
|
42
|
+
</VStack>
|
|
43
|
+
) : null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default function HomePage() {
|
|
47
|
+
const { posts, viewer } = useRequest({
|
|
48
|
+
posts: { list: PostConnectionView },
|
|
49
|
+
viewer: { view: UserView },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Section gap={32}>
|
|
54
|
+
<div
|
|
55
|
+
className={cx('grid gap-8 lg:items-stretch', viewer?.id ? 'lg:grid-cols-[1.6fr_1fr]' : '')}
|
|
56
|
+
>
|
|
57
|
+
<Card className="border border-white/20 bg-linear-to-r from-blue-500 to-sky-500 text-white dark:from-blue-600 dark:to-sky-600">
|
|
58
|
+
<Stack alignCenter gap={12} wrap>
|
|
59
|
+
<span className="squircle bg-white/20 px-2 py-1 text-xs font-semibold tracking-widest uppercase">
|
|
60
|
+
<span className="lowercase italic">fate</span> demo
|
|
61
|
+
</span>
|
|
62
|
+
</Stack>
|
|
63
|
+
<div className="space-y-3">
|
|
64
|
+
<h1 className="text-3xl leading-tight font-semibold text-balance lg:text-4xl">
|
|
65
|
+
<fbt desc="Description of fate">
|
|
66
|
+
fate is a modern data client for React inspired by Relay and GraphQL.
|
|
67
|
+
</fbt>
|
|
68
|
+
</h1>
|
|
69
|
+
<p className="text-sm text-white/80 lg:text-base">
|
|
70
|
+
<fbt desc="Tagline for fate">
|
|
71
|
+
fate combines view composition, normalized caching, data masking, Async React
|
|
72
|
+
features, and type-safe data fetching.
|
|
73
|
+
</fbt>
|
|
74
|
+
</p>
|
|
75
|
+
</div>
|
|
76
|
+
<Stack alignCenter gap={12} wrap>
|
|
77
|
+
{!viewer?.id && (
|
|
78
|
+
<>
|
|
79
|
+
<Button asChild size="sm" variant="secondary">
|
|
80
|
+
<Link className="squircle px-4 py-2 text-sm font-semibold" to="/login">
|
|
81
|
+
<fbt desc="Login button">Login</fbt>
|
|
82
|
+
</Link>
|
|
83
|
+
</Button>
|
|
84
|
+
<span className="text-sm text-white/80">
|
|
85
|
+
<fbt desc="Login button label">Sign in to post comments.</fbt>
|
|
86
|
+
</span>
|
|
87
|
+
</>
|
|
88
|
+
)}
|
|
89
|
+
</Stack>
|
|
90
|
+
</Card>
|
|
91
|
+
{viewer?.id && <UserCard user={viewer} />}
|
|
92
|
+
</div>
|
|
93
|
+
<PostFeed posts={posts} />
|
|
94
|
+
</Section>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/// <reference types="fbtee/ReactTypes.d.ts" />
|
|
2
|
+
|
|
3
|
+
import '../src/App.css';
|
|
4
|
+
import Stack from '@nkzw/stack';
|
|
5
|
+
import { httpBatchLink } from '@trpc/client';
|
|
6
|
+
import { createLocaleContext } from 'fbtee';
|
|
7
|
+
import { ReactNode, Suspense, useMemo } from 'react';
|
|
8
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
|
+
import { FateClient } from 'react-fate';
|
|
10
|
+
import { createFateClient } from 'react-fate/client';
|
|
11
|
+
import AvailableLanguages from '../src/lib/AvailableLanguages.tsx';
|
|
12
|
+
import env from '../src/lib/env.tsx';
|
|
13
|
+
import Card from '../src/ui/Card.tsx';
|
|
14
|
+
import Error from '../src/ui/Error.tsx';
|
|
15
|
+
import Header from '../src/ui/Header.tsx';
|
|
16
|
+
import Section from '../src/ui/Section.tsx';
|
|
17
|
+
import AuthClient from '../src/user/AuthClient.tsx';
|
|
18
|
+
|
|
19
|
+
const Thinking = () => (
|
|
20
|
+
<Section>
|
|
21
|
+
<Stack center className="animate-pulse text-gray-500 italic" verticalPadding={48}>
|
|
22
|
+
<fbt desc="Text for thinking/loading screen">Thinking...</fbt>
|
|
23
|
+
</Stack>
|
|
24
|
+
</Section>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const LocaleContext = createLocaleContext({
|
|
28
|
+
availableLanguages: AvailableLanguages,
|
|
29
|
+
clientLocales: [navigator.language, ...navigator.languages],
|
|
30
|
+
loadLocale: async (locale: string) => {
|
|
31
|
+
if (locale !== 'en_US' && AvailableLanguages.has(locale)) {
|
|
32
|
+
return (await import(`../src/translations/${locale}.json`)).default[locale];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export default function Layout({ children }: { children: ReactNode }) {
|
|
40
|
+
const { data: session, isPending } = AuthClient.useSession();
|
|
41
|
+
const userId = session?.user.id;
|
|
42
|
+
|
|
43
|
+
const fate = useMemo(
|
|
44
|
+
() =>
|
|
45
|
+
createFateClient({
|
|
46
|
+
links: [
|
|
47
|
+
httpBatchLink({
|
|
48
|
+
fetch: (input, init) =>
|
|
49
|
+
fetch(input, {
|
|
50
|
+
...init,
|
|
51
|
+
credentials: userId ? 'include' : undefined,
|
|
52
|
+
}),
|
|
53
|
+
url: `${env('SERVER_URL')}/trpc`,
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
}),
|
|
57
|
+
[userId],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (isPending) {
|
|
61
|
+
return (
|
|
62
|
+
<LocaleContext>
|
|
63
|
+
<div className="min-h-screen bg-background text-foreground">
|
|
64
|
+
<div className="min-h-screen bg-[radial-gradient(circle_at_20%_20%,rgba(59,130,246,0.08),transparent_35%),radial-gradient(circle_at_80%_0,rgba(99,102,241,0.08),transparent_28%)]">
|
|
65
|
+
<Thinking />
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</LocaleContext>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<LocaleContext>
|
|
74
|
+
<FateClient client={fate} key={userId}>
|
|
75
|
+
<div className="min-h-screen bg-background text-foreground">
|
|
76
|
+
<div className="min-h-screen bg-[radial-gradient(circle_at_20%_20%,rgba(59,130,246,0.08),transparent_35%),radial-gradient(circle_at_80%_0,rgba(99,102,241,0.08),transparent_28%)]">
|
|
77
|
+
<Header />
|
|
78
|
+
<ErrorBoundary
|
|
79
|
+
fallbackRender={({ error }) => (
|
|
80
|
+
<Section>
|
|
81
|
+
<Card>
|
|
82
|
+
<Error error={error} />
|
|
83
|
+
</Card>
|
|
84
|
+
</Section>
|
|
85
|
+
)}
|
|
86
|
+
>
|
|
87
|
+
<Suspense fallback={<Thinking />}>{children}</Suspense>
|
|
88
|
+
</ErrorBoundary>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</FateClient>
|
|
92
|
+
</LocaleContext>
|
|
93
|
+
);
|
|
94
|
+
}
|