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,129 @@
|
|
|
1
|
+
import safeParse from '@nkzw/core/safeParse.js';
|
|
2
|
+
import Stack, { VStack } from '@nkzw/stack';
|
|
3
|
+
import { ChangeEvent, useActionState, useState } from 'react';
|
|
4
|
+
import { useFateClient, useView, view, ViewRef } from 'react-fate';
|
|
5
|
+
import { User } from '../fate/server.ts';
|
|
6
|
+
import { Button } from '../ui/Button.tsx';
|
|
7
|
+
import Card from '../ui/Card.tsx';
|
|
8
|
+
import AuthClient from '../user/AuthClient.tsx';
|
|
9
|
+
import H2 from './H2.tsx';
|
|
10
|
+
import Input from './Input.tsx';
|
|
11
|
+
|
|
12
|
+
export type SessionUser = {
|
|
13
|
+
id?: string | null;
|
|
14
|
+
name?: string | null;
|
|
15
|
+
username?: string | null;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const UserView = view<User>()({
|
|
19
|
+
id: true,
|
|
20
|
+
name: true,
|
|
21
|
+
username: true,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const UserCardView = view<User>()({
|
|
25
|
+
email: true,
|
|
26
|
+
id: true,
|
|
27
|
+
name: true,
|
|
28
|
+
username: true,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const UserNameForm = ({ user }: { user: SessionUser }) => {
|
|
32
|
+
const fate = useFateClient();
|
|
33
|
+
const [name, setName] = useState(user.name ?? '');
|
|
34
|
+
const [error, setError] = useState<string | null>(null);
|
|
35
|
+
|
|
36
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
37
|
+
setError(null);
|
|
38
|
+
setName(event.target.value);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const [, submitAction, isPending] = useActionState(async () => {
|
|
42
|
+
const id = user?.id;
|
|
43
|
+
if (!id) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const newName = name.trim();
|
|
48
|
+
setName(newName);
|
|
49
|
+
|
|
50
|
+
if (newName === user.name) {
|
|
51
|
+
setError(null);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
setError(null);
|
|
57
|
+
await fate.mutations.user.update({
|
|
58
|
+
input: { name: newName },
|
|
59
|
+
optimistic: {
|
|
60
|
+
id,
|
|
61
|
+
username: newName,
|
|
62
|
+
},
|
|
63
|
+
view: UserView,
|
|
64
|
+
});
|
|
65
|
+
await AuthClient.updateUser({ name });
|
|
66
|
+
} catch (error) {
|
|
67
|
+
setError(
|
|
68
|
+
(error instanceof Error &&
|
|
69
|
+
error.message &&
|
|
70
|
+
safeParse<Array<{ message: string }>>(error.message)?.[0]?.message) ||
|
|
71
|
+
'Failed to update user name.',
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}, null);
|
|
75
|
+
|
|
76
|
+
const trimmedName = name.trim();
|
|
77
|
+
const originalName = user.name ?? '';
|
|
78
|
+
const isSaveDisabled = !user.id || !trimmedName || trimmedName === originalName || isPending;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
<VStack action={submitAction} as="form" gap={12}>
|
|
83
|
+
<h3 className="font-semibold">Update Name</h3>
|
|
84
|
+
<label className="sr-only" htmlFor="header-username">
|
|
85
|
+
Username
|
|
86
|
+
</label>
|
|
87
|
+
<Input
|
|
88
|
+
aria-describedby={error ? 'header-username-error' : undefined}
|
|
89
|
+
aria-invalid={error ? 'true' : undefined}
|
|
90
|
+
className="w-48"
|
|
91
|
+
disabled={isPending}
|
|
92
|
+
id="header-username"
|
|
93
|
+
name="name"
|
|
94
|
+
onChange={handleChange}
|
|
95
|
+
placeholder="Name"
|
|
96
|
+
title={error ?? undefined}
|
|
97
|
+
value={name}
|
|
98
|
+
/>
|
|
99
|
+
<div>
|
|
100
|
+
<Button disabled={isSaveDisabled} size="sm" type="submit" variant="secondary">
|
|
101
|
+
Save
|
|
102
|
+
</Button>
|
|
103
|
+
</div>
|
|
104
|
+
</VStack>
|
|
105
|
+
{error ? <span id="header-username-error">{error}</span> : null}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default function UserCard({ viewer: viewerRef }: { viewer: ViewRef<'User'> }) {
|
|
111
|
+
const viewer = useView(UserCardView, viewerRef);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Card>
|
|
115
|
+
<VStack between className="h-full" gap={16}>
|
|
116
|
+
<VStack gap={16}>
|
|
117
|
+
<H2>Your account</H2>
|
|
118
|
+
<Stack alignCenter between gap={16}>
|
|
119
|
+
<p className="text-sm text-muted-foreground">
|
|
120
|
+
Signed in as {viewer.name}
|
|
121
|
+
{viewer.email ? ` <${viewer.email}>` : null}.
|
|
122
|
+
</p>
|
|
123
|
+
</Stack>
|
|
124
|
+
</VStack>
|
|
125
|
+
<UserNameForm user={viewer} />
|
|
126
|
+
</VStack>
|
|
127
|
+
</Card>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { auth as default } from 'void/client';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UserRow } from '../../db/schema.ts';
|
|
2
|
+
|
|
3
|
+
export type SessionUser = Pick<UserRow, 'role' | 'id' | 'username'>;
|
|
4
|
+
|
|
5
|
+
export function toSessionUser({
|
|
6
|
+
email,
|
|
7
|
+
id,
|
|
8
|
+
role,
|
|
9
|
+
username,
|
|
10
|
+
}: Readonly<{
|
|
11
|
+
email: string | null | undefined;
|
|
12
|
+
id: string;
|
|
13
|
+
role?: string | null | undefined;
|
|
14
|
+
username?: string | null | undefined;
|
|
15
|
+
}>): SessionUser {
|
|
16
|
+
return { id, role: role || '', username: username || email || '' };
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./.void/tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
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": "ESNext",
|
|
12
|
+
"moduleResolution": "Bundler",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"noImplicitOverride": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"target": "ES2022",
|
|
20
|
+
"types": ["vite/client", "void/env"]
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
".fate/**/*.ts",
|
|
24
|
+
".void/**/*.d.ts",
|
|
25
|
+
"db/**/*.ts",
|
|
26
|
+
"db/**/*.tsx",
|
|
27
|
+
"middleware/**/*.ts",
|
|
28
|
+
"pages/**/*.ts",
|
|
29
|
+
"pages/**/*.tsx",
|
|
30
|
+
"routes/**/*.ts",
|
|
31
|
+
"src/**/*.ts",
|
|
32
|
+
"src/**/*.tsx"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import babel from '@rolldown/plugin-babel';
|
|
2
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
3
|
+
import { reactCompilerPreset } from '@vitejs/plugin-react';
|
|
4
|
+
import { voidReact } from '@void/react/plugin';
|
|
5
|
+
import { fate } from 'react-fate/vite';
|
|
6
|
+
import { defineConfig, lazyPlugins } from 'vite-plus';
|
|
7
|
+
import { voidPlugin } from 'void';
|
|
8
|
+
|
|
9
|
+
const isTest = process.env.NODE_ENV === 'test' || process.env.VITEST;
|
|
10
|
+
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
environments: {
|
|
13
|
+
void_worker: {
|
|
14
|
+
optimizeDeps: {
|
|
15
|
+
include: [
|
|
16
|
+
'@nkzw/core/safeParse.js',
|
|
17
|
+
'@nkzw/stack',
|
|
18
|
+
'@radix-ui/react-slot',
|
|
19
|
+
'@void/react',
|
|
20
|
+
'@void/react/pages-server',
|
|
21
|
+
'better-auth',
|
|
22
|
+
'better-auth/adapters/drizzle',
|
|
23
|
+
'better-auth/plugins',
|
|
24
|
+
'class-variance-authority',
|
|
25
|
+
'clsx',
|
|
26
|
+
'drizzle-orm',
|
|
27
|
+
'lucide-react',
|
|
28
|
+
'react',
|
|
29
|
+
'react-error-boundary',
|
|
30
|
+
'react/jsx-dev-runtime',
|
|
31
|
+
'react/jsx-runtime',
|
|
32
|
+
'tailwind-merge',
|
|
33
|
+
'void/schema-d1',
|
|
34
|
+
'zod',
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
fmt: {
|
|
40
|
+
experimentalSortImports: {
|
|
41
|
+
newlinesBetween: false,
|
|
42
|
+
},
|
|
43
|
+
experimentalSortPackageJson: {
|
|
44
|
+
sortScripts: true,
|
|
45
|
+
},
|
|
46
|
+
experimentalTailwindcss: {
|
|
47
|
+
stylesheet: 'src/App.css',
|
|
48
|
+
},
|
|
49
|
+
ignorePatterns: ['.fate/', '.void/', 'dist/', 'node_modules/', 'pnpm-lock.yaml'],
|
|
50
|
+
singleQuote: true,
|
|
51
|
+
},
|
|
52
|
+
lint: {
|
|
53
|
+
ignorePatterns: ['.fate', '.void', 'dist', 'node_modules', 'vite.config.ts.timestamp-*'],
|
|
54
|
+
options: { typeAware: true, typeCheck: true },
|
|
55
|
+
overrides: [
|
|
56
|
+
{
|
|
57
|
+
files: ['db/seed.ts', 'src/fate/__tests__/**'],
|
|
58
|
+
rules: {
|
|
59
|
+
'no-console': 'off',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
rules: {
|
|
64
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
plugins: [
|
|
68
|
+
...(lazyPlugins(() => [
|
|
69
|
+
babel({
|
|
70
|
+
presets: [reactCompilerPreset()],
|
|
71
|
+
}),
|
|
72
|
+
tailwindcss(),
|
|
73
|
+
...(isTest ? [] : [voidPlugin(), voidReact()]),
|
|
74
|
+
]) ?? []),
|
|
75
|
+
fate({
|
|
76
|
+
module: './src/fate/server.ts',
|
|
77
|
+
transport: 'void',
|
|
78
|
+
}),
|
|
79
|
+
],
|
|
80
|
+
resolve: { conditions: ['@nkzw/source'] },
|
|
81
|
+
server: { port: 6001 },
|
|
82
|
+
ssr: { noExternal: ['void-fate'] },
|
|
83
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/void/schema.json",
|
|
3
|
+
"auth": {
|
|
4
|
+
"providers": ["email"]
|
|
5
|
+
},
|
|
6
|
+
"head": {
|
|
7
|
+
"title": "fate",
|
|
8
|
+
"titleTemplate": "%s | fate",
|
|
9
|
+
"htmlAttrs": {
|
|
10
|
+
"lang": "en"
|
|
11
|
+
},
|
|
12
|
+
"meta": [
|
|
13
|
+
{
|
|
14
|
+
"charset": "utf-8"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "viewport",
|
|
18
|
+
"content": "width=device-width, initial-scale=1"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"link": [
|
|
22
|
+
{
|
|
23
|
+
"rel": "icon",
|
|
24
|
+
"href": "/icon.svg"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"worker": {
|
|
29
|
+
"compatibility_date": "2025-12-01",
|
|
30
|
+
"compatibility_flags": ["nodejs_compat", "no_handle_cross_request_promise_resolution"]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"durable_objects": {
|
|
3
|
+
"bindings": [
|
|
4
|
+
{
|
|
5
|
+
"name": "VOID_LIVE",
|
|
6
|
+
"class_name": "VoidLiveStreamDurableObject",
|
|
7
|
+
},
|
|
8
|
+
],
|
|
9
|
+
},
|
|
10
|
+
"migrations": [
|
|
11
|
+
{
|
|
12
|
+
"tag": "live-v1",
|
|
13
|
+
"new_sqlite_classes": ["VoidLiveStreamDurableObject"],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
}
|