create-thexjs-app 0.1.4 → 1.1.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/README.md +56 -985
- package/dist/index.js +265 -196
- package/package.json +5 -1
- package/templates/{basic → addons/auth}/src/api/auth/login.ts +1 -3
- package/templates/{basic → addons/auth}/src/lib/auth.ts +13 -9
- package/templates/{basic → addons/auth}/src/lib/migrations/001_create_sessions.sql +1 -3
- package/templates/addons/auth/src/pages/dashboard/index.tsx +39 -0
- package/templates/addons/auth/src/pages/login.tsx +72 -0
- package/templates/addons/content/content/hello-world.md +13 -0
- package/templates/addons/content/src/pages/blog.tsx +29 -0
- package/templates/{basic → addons/shadcn}/components.json +1 -1
- package/templates/addons/shadcn/src/components/ui/badge.tsx +17 -0
- package/templates/addons/shadcn/src/components/ui/button.tsx +36 -0
- package/templates/addons/shadcn/src/components/ui/card.tsx +33 -0
- package/templates/addons/shadcn/src/components/ui/input.tsx +18 -0
- package/templates/addons/tailwind/src/styles/globals.css +32 -0
- package/templates/base/src/pages/index.tsx +29 -0
- package/templates/base/src/styles/globals.css +22 -0
- package/templates/base/tsconfig.json +24 -0
- package/templates/basic/content/blog/hello.md +0 -8
- package/templates/basic/public/favicon.ico +0 -0
- package/templates/basic/src/actions/dashboard/greet.ts +0 -3
- package/templates/basic/src/api/placeholder/comments.ts +0 -17
- package/templates/basic/src/api/placeholder/posts.ts +0 -20
- package/templates/basic/src/api/placeholder/todos.ts +0 -21
- package/templates/basic/src/api/placeholder/users.ts +0 -12
- package/templates/basic/src/components/Head.tsx +0 -21
- package/templates/basic/src/components/Image.tsx +0 -27
- package/templates/basic/src/components/Link.tsx +0 -10
- package/templates/basic/src/components/ui/badge.tsx +0 -49
- package/templates/basic/src/components/ui/button.tsx +0 -58
- package/templates/basic/src/components/ui/card.tsx +0 -88
- package/templates/basic/src/components/ui/input.tsx +0 -20
- package/templates/basic/src/layouts/main.tsx +0 -38
- package/templates/basic/src/lib/placeholder-data.ts +0 -176
- package/templates/basic/src/pages/_404.tsx +0 -17
- package/templates/basic/src/pages/about.tsx +0 -22
- package/templates/basic/src/pages/blog.tsx +0 -41
- package/templates/basic/src/pages/dashboard/index.tsx +0 -84
- package/templates/basic/src/pages/index.tsx +0 -54
- package/templates/basic/src/pages/login.tsx +0 -92
- package/templates/basic/src/pages/placeholder.tsx +0 -203
- package/templates/basic/src/pages/posts/[id].tsx +0 -17
- package/templates/basic/src/styles/globals.css +0 -90
- package/templates/basic/src/x-routes.ts +0 -29
- package/templates/basic/tsconfig.json +0 -11
- package/templates/basic/x.config.ts +0 -10
- package/templates/blog/components.json +0 -20
- package/templates/blog/content/posts/getting-started.md +0 -38
- package/templates/blog/content/posts/hello-world.md +0 -21
- package/templates/blog/content/posts/tailwind-v4.md +0 -31
- package/templates/blog/public/favicon.ico +0 -0
- package/templates/blog/src/components/ui/avatar.tsx +0 -91
- package/templates/blog/src/components/ui/badge.tsx +0 -49
- package/templates/blog/src/components/ui/button.tsx +0 -58
- package/templates/blog/src/components/ui/card.tsx +0 -88
- package/templates/blog/src/components/ui/input.tsx +0 -20
- package/templates/blog/src/layouts/blog.tsx +0 -46
- package/templates/blog/src/layouts/main.tsx +0 -32
- package/templates/blog/src/lib/utils.ts +0 -5
- package/templates/blog/src/pages/about.tsx +0 -36
- package/templates/blog/src/pages/blog/[slug].tsx +0 -56
- package/templates/blog/src/pages/blog/index.tsx +0 -70
- package/templates/blog/src/pages/index.tsx +0 -73
- package/templates/blog/src/styles/globals.css +0 -90
- package/templates/blog/src/x-routes.ts +0 -20
- package/templates/blog/tsconfig.json +0 -5
- package/templates/blog/x.config.ts +0 -6
- package/templates/default/components.json +0 -19
- package/templates/default/src/layouts/main.tsx +0 -28
- package/templates/default/src/pages/index.tsx +0 -66
- package/templates/default/src/styles/globals.css +0 -55
- package/templates/default/src/x-routes.ts +0 -17
- package/templates/default/tsconfig.json +0 -5
- package/templates/default/x.config.ts +0 -6
- package/templates/landing/components.json +0 -20
- package/templates/landing/public/favicon.ico +0 -0
- package/templates/landing/src/components/code-block.tsx +0 -118
- package/templates/landing/src/components/ui/avatar.tsx +0 -91
- package/templates/landing/src/components/ui/badge.tsx +0 -49
- package/templates/landing/src/components/ui/button.tsx +0 -58
- package/templates/landing/src/components/ui/card.tsx +0 -88
- package/templates/landing/src/components/ui/input.tsx +0 -20
- package/templates/landing/src/layouts/main.tsx +0 -78
- package/templates/landing/src/lib/syntax.tsx +0 -366
- package/templates/landing/src/lib/utils.ts +0 -5
- package/templates/landing/src/pages/docs/_layout.tsx +0 -139
- package/templates/landing/src/pages/docs/api-routes.tsx +0 -113
- package/templates/landing/src/pages/docs/build-deploy.tsx +0 -124
- package/templates/landing/src/pages/docs/configuration.tsx +0 -121
- package/templates/landing/src/pages/docs/content-collections.tsx +0 -130
- package/templates/landing/src/pages/docs/data-layer.tsx +0 -142
- package/templates/landing/src/pages/docs/getting-started.tsx +0 -129
- package/templates/landing/src/pages/docs/index.tsx +0 -187
- package/templates/landing/src/pages/docs/installation.tsx +0 -143
- package/templates/landing/src/pages/docs/introduction.tsx +0 -114
- package/templates/landing/src/pages/docs/layouts.tsx +0 -114
- package/templates/landing/src/pages/docs/middleware.tsx +0 -124
- package/templates/landing/src/pages/docs/packages/cli.tsx +0 -133
- package/templates/landing/src/pages/docs/packages/core.tsx +0 -176
- package/templates/landing/src/pages/docs/packages/env.tsx +0 -128
- package/templates/landing/src/pages/docs/pages.tsx +0 -135
- package/templates/landing/src/pages/docs/routing.tsx +0 -123
- package/templates/landing/src/pages/docs/server-functions.tsx +0 -177
- package/templates/landing/src/pages/features.tsx +0 -129
- package/templates/landing/src/pages/index.tsx +0 -159
- package/templates/landing/src/styles/globals.css +0 -136
- package/templates/landing/src/x-routes.ts +0 -31
- package/templates/landing/tsconfig.json +0 -10
- package/templates/landing/x.config.ts +0 -2
- package/templates/saas/components.json +0 -20
- package/templates/saas/public/favicon.ico +0 -0
- package/templates/saas/src/actions/dashboard.ts +0 -3
- package/templates/saas/src/api/auth/login.ts +0 -31
- package/templates/saas/src/components/ui/avatar.tsx +0 -91
- package/templates/saas/src/components/ui/badge.tsx +0 -49
- package/templates/saas/src/components/ui/button.tsx +0 -58
- package/templates/saas/src/components/ui/card.tsx +0 -88
- package/templates/saas/src/components/ui/input.tsx +0 -20
- package/templates/saas/src/layouts/dashboard.tsx +0 -67
- package/templates/saas/src/layouts/main.tsx +0 -38
- package/templates/saas/src/lib/auth.ts +0 -91
- package/templates/saas/src/lib/migrations/001_create_sessions.sql +0 -9
- package/templates/saas/src/lib/utils.ts +0 -5
- package/templates/saas/src/pages/dashboard/_middleware.ts +0 -9
- package/templates/saas/src/pages/dashboard/analytics.tsx +0 -68
- package/templates/saas/src/pages/dashboard/index.tsx +0 -86
- package/templates/saas/src/pages/dashboard/settings.tsx +0 -111
- package/templates/saas/src/pages/index.tsx +0 -110
- package/templates/saas/src/pages/login.tsx +0 -140
- package/templates/saas/src/pages/pricing.tsx +0 -121
- package/templates/saas/src/styles/globals.css +0 -90
- package/templates/saas/src/x-routes.ts +0 -22
- package/templates/saas/tsconfig.json +0 -5
- package/templates/saas/x.config.ts +0 -7
- /package/templates/{basic → addons/auth}/src/api/auth/logout.ts +0 -0
- /package/templates/{basic → addons/auth}/src/pages/dashboard/_middleware.ts +0 -0
- /package/templates/{basic → addons/shadcn}/src/lib/utils.ts +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type * as React from "react";
|
|
2
|
-
|
|
3
|
-
import { cn } from "@/lib/utils";
|
|
4
|
-
|
|
5
|
-
function Card({
|
|
6
|
-
className,
|
|
7
|
-
size = "default",
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
|
|
10
|
-
return (
|
|
11
|
-
<div
|
|
12
|
-
data-slot="card"
|
|
13
|
-
data-size={size}
|
|
14
|
-
className={cn(
|
|
15
|
-
"group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
|
|
16
|
-
className,
|
|
17
|
-
)}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
data-slot="card-header"
|
|
27
|
-
className={cn(
|
|
28
|
-
"group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
|
|
29
|
-
className,
|
|
30
|
-
)}
|
|
31
|
-
{...props}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
37
|
-
return (
|
|
38
|
-
<div
|
|
39
|
-
data-slot="card-title"
|
|
40
|
-
className={cn(
|
|
41
|
-
"text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
|
|
42
|
-
className,
|
|
43
|
-
)}
|
|
44
|
-
{...props}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
50
|
-
return (
|
|
51
|
-
<div
|
|
52
|
-
data-slot="card-description"
|
|
53
|
-
className={cn("text-sm text-muted-foreground", className)}
|
|
54
|
-
{...props}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
60
|
-
return (
|
|
61
|
-
<div
|
|
62
|
-
data-slot="card-action"
|
|
63
|
-
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
|
64
|
-
{...props}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
70
|
-
return (
|
|
71
|
-
<div data-slot="card-content" className={cn("px-(--card-spacing)", className)} {...props} />
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
76
|
-
return (
|
|
77
|
-
<div
|
|
78
|
-
data-slot="card-footer"
|
|
79
|
-
className={cn(
|
|
80
|
-
"flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
|
|
81
|
-
className,
|
|
82
|
-
)}
|
|
83
|
-
{...props}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
2
|
-
import type * as React from "react";
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils";
|
|
5
|
-
|
|
6
|
-
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
7
|
-
return (
|
|
8
|
-
<InputPrimitive
|
|
9
|
-
type={type}
|
|
10
|
-
data-slot="input"
|
|
11
|
-
className={cn(
|
|
12
|
-
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
13
|
-
className,
|
|
14
|
-
)}
|
|
15
|
-
{...props}
|
|
16
|
-
/>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { Input };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
4
|
-
return (
|
|
5
|
-
<>
|
|
6
|
-
<nav className="flex items-center gap-6 border-b border-border px-6 py-3">
|
|
7
|
-
<a href="/" className="font-bold text-lg">
|
|
8
|
-
x
|
|
9
|
-
</a>
|
|
10
|
-
<a
|
|
11
|
-
href="/about"
|
|
12
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
13
|
-
>
|
|
14
|
-
About
|
|
15
|
-
</a>
|
|
16
|
-
<a
|
|
17
|
-
href="/dashboard"
|
|
18
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
19
|
-
>
|
|
20
|
-
Dashboard
|
|
21
|
-
</a>
|
|
22
|
-
<a
|
|
23
|
-
href="/posts"
|
|
24
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
25
|
-
>
|
|
26
|
-
Posts
|
|
27
|
-
</a>
|
|
28
|
-
<a
|
|
29
|
-
href="/placeholder"
|
|
30
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
31
|
-
>
|
|
32
|
-
Placeholder
|
|
33
|
-
</a>
|
|
34
|
-
</nav>
|
|
35
|
-
<main className="mx-auto max-w-3xl px-4 py-8">{children}</main>
|
|
36
|
-
</>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
const titles = [
|
|
2
|
-
"sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
|
|
3
|
-
"qui est esse",
|
|
4
|
-
"ea molestias quasi exercitationem repellat qui ipsa sit aut",
|
|
5
|
-
"eum et est occaecati",
|
|
6
|
-
"nesciunt quas odio",
|
|
7
|
-
"dolorem eum magni eos aperiam quia",
|
|
8
|
-
"magnam facilis autem",
|
|
9
|
-
"dolorem dolore est ipsam",
|
|
10
|
-
"nesciunt iure omnis dolorem tempora et accusantium",
|
|
11
|
-
"optio molestias id quia eum",
|
|
12
|
-
"et iusto sed quo iure",
|
|
13
|
-
"ullam et saepe reiciendis voluptatem adipisci",
|
|
14
|
-
"repudiandae veniam quaerat sunt sed",
|
|
15
|
-
"aspernatur aperiam consequatur",
|
|
16
|
-
"ratione porro quas",
|
|
17
|
-
"sapiente assumenda molestiae atque",
|
|
18
|
-
"ut voluptatum aliquid illo tenetur",
|
|
19
|
-
"adipisci placeat illum aut reiciendis",
|
|
20
|
-
"doloribus ad provident suscipit at",
|
|
21
|
-
"id maiores molestias",
|
|
22
|
-
"alias distinctio fugit",
|
|
23
|
-
"et fugit quod quis",
|
|
24
|
-
"et quia tempora",
|
|
25
|
-
"quasi fugit ut totam",
|
|
26
|
-
"doloremque autem similique et",
|
|
27
|
-
"veritatis unde neque",
|
|
28
|
-
"officiis quia ullam deleniti",
|
|
29
|
-
"quo voluptatem dolorum",
|
|
30
|
-
"atque suscipit voluptatem ab",
|
|
31
|
-
"excepturi aut ut praesentium",
|
|
32
|
-
];
|
|
33
|
-
const bodies = [
|
|
34
|
-
"quia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto",
|
|
35
|
-
"est rerum tempore vitae sequi sint nihil reprehenderit dolor beatae ea dolores neque fugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis qui aperiam non debitis possimus qui neque nisi nulla",
|
|
36
|
-
"quia molestiae reprehenderit quasi aspernatur aut expedita occaecati aliquam eveniet laudantium omnis quibusdam delectus saepe quia accusamus maiores nam est cum et ducimus et vero voluptates excepturi deleniti ratione",
|
|
37
|
-
"non et atque occaecati deserunt quas accusantium unde odit nobis qui voluptatem quia voluptas consequuntur itaque dolor et qui rerum deleniti ut occaecati",
|
|
38
|
-
"harum non quasi et ratione tempore iure ex voluptates in ratione harum architecto fugit inventore cupiditate voluptates magni quo et",
|
|
39
|
-
"doloremque ex facilis sit sint culpa soluta assumenda eligendi ut ut voluptate et non ipsa doloremque repellendus quas est cum quibusdam impedit",
|
|
40
|
-
];
|
|
41
|
-
const firstNames = [
|
|
42
|
-
"Leanne",
|
|
43
|
-
"Ervin",
|
|
44
|
-
"Clementine",
|
|
45
|
-
"Patricia",
|
|
46
|
-
"Chelsey",
|
|
47
|
-
"Mrs.Dennis",
|
|
48
|
-
"Kurtis",
|
|
49
|
-
"Nicholas",
|
|
50
|
-
"Glenna",
|
|
51
|
-
"Clementina",
|
|
52
|
-
];
|
|
53
|
-
const lastNames = [
|
|
54
|
-
"Graham",
|
|
55
|
-
"Howell",
|
|
56
|
-
"Bauch",
|
|
57
|
-
"Lebsack",
|
|
58
|
-
"Dietrich",
|
|
59
|
-
"Schulist",
|
|
60
|
-
"Weissnat",
|
|
61
|
-
"Runolfsdottir",
|
|
62
|
-
"Reichert",
|
|
63
|
-
"DuBuque",
|
|
64
|
-
];
|
|
65
|
-
const emails = [
|
|
66
|
-
"Sincere@april.biz",
|
|
67
|
-
"Shanna@melissa.tv",
|
|
68
|
-
"Nathan@yesenia.net",
|
|
69
|
-
"Julianne.OConner@kory.org",
|
|
70
|
-
"Lucio_Hettinger@annie.ca",
|
|
71
|
-
"Karley_Dach@jasper.info",
|
|
72
|
-
"Telly.Hoeger@billy.biz",
|
|
73
|
-
"Sherwood@rosamond.me",
|
|
74
|
-
"Chaim_McDermott@dana.io",
|
|
75
|
-
"Rey.Padberg@karina.biz",
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
function pick<T>(arr: T[], i: number): T {
|
|
79
|
-
return arr[i % arr.length] as T;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface Post {
|
|
83
|
-
userId: number;
|
|
84
|
-
id: number;
|
|
85
|
-
title: string;
|
|
86
|
-
body: string;
|
|
87
|
-
}
|
|
88
|
-
export interface Comment {
|
|
89
|
-
postId: number;
|
|
90
|
-
id: number;
|
|
91
|
-
name: string;
|
|
92
|
-
email: string;
|
|
93
|
-
body: string;
|
|
94
|
-
}
|
|
95
|
-
export interface Todo {
|
|
96
|
-
userId: number;
|
|
97
|
-
id: number;
|
|
98
|
-
title: string;
|
|
99
|
-
completed: boolean;
|
|
100
|
-
}
|
|
101
|
-
export interface User {
|
|
102
|
-
id: number;
|
|
103
|
-
name: string;
|
|
104
|
-
username: string;
|
|
105
|
-
email: string;
|
|
106
|
-
address: { street: string; suite: string; city: string; zipcode: string };
|
|
107
|
-
phone: string;
|
|
108
|
-
website: string;
|
|
109
|
-
company: { name: string; catchPhrase: string; bs: string };
|
|
110
|
-
}
|
|
111
|
-
export interface Album {
|
|
112
|
-
userId: number;
|
|
113
|
-
id: number;
|
|
114
|
-
title: string;
|
|
115
|
-
}
|
|
116
|
-
export interface Photo {
|
|
117
|
-
albumId: number;
|
|
118
|
-
id: number;
|
|
119
|
-
title: string;
|
|
120
|
-
url: string;
|
|
121
|
-
thumbnailUrl: string;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const posts: Post[] = Array.from({ length: 100 }, (_, i) => ({
|
|
125
|
-
userId: (i % 10) + 1,
|
|
126
|
-
id: i + 1,
|
|
127
|
-
title: pick(titles, i),
|
|
128
|
-
body: pick(bodies, i),
|
|
129
|
-
}));
|
|
130
|
-
|
|
131
|
-
const comments: Comment[] = Array.from({ length: 500 }, (_, i) => ({
|
|
132
|
-
postId: (i % 100) + 1,
|
|
133
|
-
id: i + 1,
|
|
134
|
-
name: `comment ${i + 1}`,
|
|
135
|
-
email: pick(emails, i),
|
|
136
|
-
body: "laudantium enim quasi est quidem magnam voluptate ipsam eos tempora quo necessitatibus dolor quam autem quasi reiciendis et nam sapiente accusantium",
|
|
137
|
-
}));
|
|
138
|
-
|
|
139
|
-
const todos: Todo[] = Array.from({ length: 200 }, (_, i) => ({
|
|
140
|
-
userId: (i % 10) + 1,
|
|
141
|
-
id: i + 1,
|
|
142
|
-
title: pick(titles, i * 3 + 2),
|
|
143
|
-
completed: i % 3 === 0,
|
|
144
|
-
}));
|
|
145
|
-
|
|
146
|
-
const users: User[] = Array.from({ length: 10 }, (_, i) => ({
|
|
147
|
-
id: i + 1,
|
|
148
|
-
name: `${pick(firstNames, i)} ${pick(lastNames, i)}`,
|
|
149
|
-
username: pick(lastNames, i).toLowerCase(),
|
|
150
|
-
email: pick(emails, i),
|
|
151
|
-
address: {
|
|
152
|
-
street: `Street ${i + 1}`,
|
|
153
|
-
suite: `Suite ${i + 1}`,
|
|
154
|
-
city: `City ${i + 1}`,
|
|
155
|
-
zipcode: `${10000 + i * 100}`,
|
|
156
|
-
},
|
|
157
|
-
phone: `1-770-736-8031 x564${i}`,
|
|
158
|
-
website: `${pick(lastNames, i).toLowerCase()}.org`,
|
|
159
|
-
company: { name: `Company ${i + 1}`, catchPhrase: `Catchphrase ${i + 1}`, bs: `BS ${i + 1}` },
|
|
160
|
-
}));
|
|
161
|
-
|
|
162
|
-
const albums: Album[] = Array.from({ length: 100 }, (_, i) => ({
|
|
163
|
-
userId: (i % 10) + 1,
|
|
164
|
-
id: i + 1,
|
|
165
|
-
title: pick(titles, i * 2),
|
|
166
|
-
}));
|
|
167
|
-
|
|
168
|
-
const photos: Photo[] = Array.from({ length: 100 }, (_, i) => ({
|
|
169
|
-
albumId: (i % 100) + 1,
|
|
170
|
-
id: i + 1,
|
|
171
|
-
title: pick(titles, i * 3),
|
|
172
|
-
url: `https://via.placeholder.com/600/${100000 + i}`,
|
|
173
|
-
thumbnailUrl: `https://via.placeholder.com/150/${100000 + i}`,
|
|
174
|
-
}));
|
|
175
|
-
|
|
176
|
-
export const data = { posts, comments, todos, users, albums, photos };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { RouteProps } from "@thexjs/core";
|
|
2
|
-
import Link from "../components/Link";
|
|
3
|
-
|
|
4
|
-
export default function CustomNotFound(_props: RouteProps) {
|
|
5
|
-
return (
|
|
6
|
-
<div className="text-center py-16">
|
|
7
|
-
<h1 className="text-6xl font-extrabold text-primary mb-2">404</h1>
|
|
8
|
-
<p className="text-lg mb-8 text-muted-foreground">This page doesn't exist.</p>
|
|
9
|
-
<Link
|
|
10
|
-
href="/"
|
|
11
|
-
className="inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors"
|
|
12
|
-
>
|
|
13
|
-
Back to home
|
|
14
|
-
</Link>
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const mode = "static";
|
|
2
|
-
|
|
3
|
-
export default function AboutPage() {
|
|
4
|
-
return (
|
|
5
|
-
<div className="space-y-4">
|
|
6
|
-
<h1 className="text-3xl font-bold">About</h1>
|
|
7
|
-
<p className="text-muted-foreground">
|
|
8
|
-
This page is marked as{" "}
|
|
9
|
-
<code className="bg-muted px-1.5 py-0.5 rounded text-sm">static</code> and prerendered at
|
|
10
|
-
build time.
|
|
11
|
-
</p>
|
|
12
|
-
<p>
|
|
13
|
-
<a
|
|
14
|
-
href="/"
|
|
15
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
16
|
-
>
|
|
17
|
-
← Back home
|
|
18
|
-
</a>
|
|
19
|
-
</p>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { scanContent } from "@thexjs/core";
|
|
3
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
4
|
-
|
|
5
|
-
export async function loader(_args: LoaderArgs) {
|
|
6
|
-
const contentDir = join(import.meta.dir, "..", "..", "content");
|
|
7
|
-
const entries = scanContent(contentDir);
|
|
8
|
-
return {
|
|
9
|
-
entries: entries.map((e) => ({ routePath: e.routePath, title: e.frontmatter.title ?? e.slug })),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function BlogPage({ loaderData }: RouteProps) {
|
|
14
|
-
const entries = (loaderData?.entries ?? []) as { routePath: string; title: string }[];
|
|
15
|
-
return (
|
|
16
|
-
<div className="space-y-6">
|
|
17
|
-
<h1 className="text-3xl font-bold">Blog</h1>
|
|
18
|
-
{entries.length === 0 ? (
|
|
19
|
-
<p className="text-muted-foreground">No posts yet.</p>
|
|
20
|
-
) : (
|
|
21
|
-
<ul className="space-y-2">
|
|
22
|
-
{entries.map((entry) => (
|
|
23
|
-
<li key={entry.routePath}>
|
|
24
|
-
<a href={entry.routePath} className="text-primary hover:underline">
|
|
25
|
-
{entry.title}
|
|
26
|
-
</a>
|
|
27
|
-
</li>
|
|
28
|
-
))}
|
|
29
|
-
</ul>
|
|
30
|
-
)}
|
|
31
|
-
<p className="pt-4">
|
|
32
|
-
<a
|
|
33
|
-
href="/"
|
|
34
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
35
|
-
>
|
|
36
|
-
← Back home
|
|
37
|
-
</a>
|
|
38
|
-
</p>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import Head from "../../components/Head";
|
|
3
|
-
import { Button } from "../../components/ui/button";
|
|
4
|
-
import { getSession, parseSessionCookie } from "../../lib/auth";
|
|
5
|
-
|
|
6
|
-
export async function loader({ request }: LoaderArgs) {
|
|
7
|
-
const token = parseSessionCookie(request.headers.get("Cookie"));
|
|
8
|
-
const session = getSession(token);
|
|
9
|
-
if (!session) {
|
|
10
|
-
return new Response(null, { status: 302, headers: { Location: "/login" } });
|
|
11
|
-
}
|
|
12
|
-
return { username: session.username };
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default function DashboardPage({ loaderData }: RouteProps) {
|
|
16
|
-
const username = (loaderData?.username as string) ?? "User";
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<>
|
|
20
|
-
<Head title={`Dashboard — ${username}`} description="User dashboard" />
|
|
21
|
-
<div className="space-y-6">
|
|
22
|
-
<h1 className="text-3xl font-bold">Dashboard</h1>
|
|
23
|
-
<p className="text-muted-foreground">Welcome, {username}!</p>
|
|
24
|
-
<hr className="border-border" />
|
|
25
|
-
<div className="space-y-4">
|
|
26
|
-
<h2 className="text-xl font-semibold">Server Functions Demo</h2>
|
|
27
|
-
<div className="flex items-center gap-3">
|
|
28
|
-
<Button type="button" data-test-id="greet-btn" variant="outline">
|
|
29
|
-
Greet
|
|
30
|
-
</Button>
|
|
31
|
-
<span id="greeting-result" className="italic text-muted-foreground" />
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
<hr className="border-border" />
|
|
35
|
-
<div className="flex items-center gap-3">
|
|
36
|
-
<Button type="button" variant="destructive" id="logout-btn">
|
|
37
|
-
Logout
|
|
38
|
-
</Button>
|
|
39
|
-
<a
|
|
40
|
-
href="/"
|
|
41
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
42
|
-
>
|
|
43
|
-
← Back home
|
|
44
|
-
</a>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
<script
|
|
48
|
-
dangerouslySetInnerHTML={{
|
|
49
|
-
__html: `
|
|
50
|
-
(function() {
|
|
51
|
-
var greetBtn = document.querySelector('[data-test-id="greet-btn"]');
|
|
52
|
-
var result = document.getElementById('greeting-result');
|
|
53
|
-
if (greetBtn) {
|
|
54
|
-
greetBtn.onclick = function() {
|
|
55
|
-
result.textContent = 'Loading...';
|
|
56
|
-
fetch('/__x/actions/dashboard/greet', {
|
|
57
|
-
method: 'POST',
|
|
58
|
-
headers: { 'Content-Type': 'application/json' },
|
|
59
|
-
body: JSON.stringify(["Dashboard User"])
|
|
60
|
-
}).then(function(r) {
|
|
61
|
-
if (r.ok) return r.text();
|
|
62
|
-
throw new Error('Request failed');
|
|
63
|
-
}).then(function(text) {
|
|
64
|
-
result.textContent = text;
|
|
65
|
-
}).catch(function() {
|
|
66
|
-
result.textContent = 'Error';
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
var logoutBtn = document.getElementById('logout-btn');
|
|
71
|
-
if (logoutBtn) {
|
|
72
|
-
logoutBtn.onclick = function() {
|
|
73
|
-
fetch('/api/auth/logout', { method: 'POST' }).then(function() {
|
|
74
|
-
window.location.href = '/';
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
})();
|
|
79
|
-
`.trim(),
|
|
80
|
-
}}
|
|
81
|
-
/>
|
|
82
|
-
</>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export default function HomePage() {
|
|
2
|
-
return (
|
|
3
|
-
<div className="space-y-8">
|
|
4
|
-
<div>
|
|
5
|
-
<h1 className="text-3xl font-bold mb-2">x</h1>
|
|
6
|
-
<p className="text-muted-foreground">
|
|
7
|
-
Static-first frontend, dynamic backend, one Bun process.
|
|
8
|
-
</p>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<section className="space-y-3">
|
|
12
|
-
<h2 className="text-xl font-semibold">Marketing / Blog (static + content collections)</h2>
|
|
13
|
-
<ul className="list-disc list-inside space-y-1 text-muted-foreground">
|
|
14
|
-
<li>
|
|
15
|
-
<a href="/about" className="text-foreground hover:underline">
|
|
16
|
-
About — static page (mode=static)
|
|
17
|
-
</a>
|
|
18
|
-
</li>
|
|
19
|
-
<li>
|
|
20
|
-
<a href="/blog" className="text-foreground hover:underline">
|
|
21
|
-
Blog listing — server-rendered with loader
|
|
22
|
-
</a>
|
|
23
|
-
</li>
|
|
24
|
-
<li>
|
|
25
|
-
<a href="/blog/hello" className="text-foreground hover:underline">
|
|
26
|
-
Hello — content collection entry
|
|
27
|
-
</a>
|
|
28
|
-
</li>
|
|
29
|
-
<li>
|
|
30
|
-
<a href="/posts/hello-world" className="text-foreground hover:underline">
|
|
31
|
-
Posts/:id — server-rendered dynamic route
|
|
32
|
-
</a>
|
|
33
|
-
</li>
|
|
34
|
-
</ul>
|
|
35
|
-
</section>
|
|
36
|
-
|
|
37
|
-
<section className="space-y-3">
|
|
38
|
-
<h2 className="text-xl font-semibold">Dashboard (SSR + server functions + auth)</h2>
|
|
39
|
-
<ul className="list-disc list-inside space-y-1 text-muted-foreground">
|
|
40
|
-
<li>
|
|
41
|
-
<a href="/dashboard" className="text-foreground hover:underline">
|
|
42
|
-
Dashboard — protected, requires login
|
|
43
|
-
</a>
|
|
44
|
-
</li>
|
|
45
|
-
<li>
|
|
46
|
-
<a href="/login" className="text-foreground hover:underline">
|
|
47
|
-
Login page
|
|
48
|
-
</a>
|
|
49
|
-
</li>
|
|
50
|
-
</ul>
|
|
51
|
-
</section>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Button } from "../components/ui/button";
|
|
4
|
-
import { Input } from "../components/ui/input";
|
|
5
|
-
import { createSession, setSessionCookie } from "../lib/auth";
|
|
6
|
-
|
|
7
|
-
export async function loader({ request }: LoaderArgs) {
|
|
8
|
-
if (request.method === "POST") {
|
|
9
|
-
const formData = await request.formData();
|
|
10
|
-
const username = formData.get("username") as string | null;
|
|
11
|
-
const password = formData.get("password") as string | null;
|
|
12
|
-
if (username === "admin" && password === "admin") {
|
|
13
|
-
const session = createSession(username);
|
|
14
|
-
return new Response(null, {
|
|
15
|
-
status: 302,
|
|
16
|
-
headers: { Location: "/dashboard", "Set-Cookie": setSessionCookie(session.token) },
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
return { error: "Invalid credentials" };
|
|
20
|
-
}
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default function LoginPage({ loaderData }: RouteProps) {
|
|
25
|
-
const [error, setError] = useState((loaderData?.error as string) ?? "");
|
|
26
|
-
const [loading, setLoading] = useState(false);
|
|
27
|
-
|
|
28
|
-
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
|
29
|
-
e.preventDefault();
|
|
30
|
-
setError("");
|
|
31
|
-
setLoading(true);
|
|
32
|
-
const form = e.currentTarget;
|
|
33
|
-
const data = { username: form.username.value, password: form.password.value };
|
|
34
|
-
try {
|
|
35
|
-
const res = await fetch("/api/auth/login", {
|
|
36
|
-
method: "POST",
|
|
37
|
-
headers: { "Content-Type": "application/json" },
|
|
38
|
-
body: JSON.stringify(data),
|
|
39
|
-
});
|
|
40
|
-
if (res.ok) {
|
|
41
|
-
window.location.href = "/dashboard";
|
|
42
|
-
} else {
|
|
43
|
-
const err = await res.json();
|
|
44
|
-
setError(err.error || "Login failed");
|
|
45
|
-
}
|
|
46
|
-
} catch {
|
|
47
|
-
setError("Network error");
|
|
48
|
-
} finally {
|
|
49
|
-
setLoading(false);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<div className="mx-auto max-w-sm mt-16 space-y-6">
|
|
55
|
-
<h1 className="text-2xl font-bold text-center">Login</h1>
|
|
56
|
-
<form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-4">
|
|
57
|
-
<div className="space-y-2">
|
|
58
|
-
<label htmlFor="username" className="text-sm font-medium">
|
|
59
|
-
Username
|
|
60
|
-
</label>
|
|
61
|
-
<Input id="username" name="username" defaultValue="admin" required />
|
|
62
|
-
</div>
|
|
63
|
-
<div className="space-y-2">
|
|
64
|
-
<label htmlFor="password" className="text-sm font-medium">
|
|
65
|
-
Password
|
|
66
|
-
</label>
|
|
67
|
-
<Input id="password" name="password" type="password" defaultValue="admin" required />
|
|
68
|
-
</div>
|
|
69
|
-
{error && (
|
|
70
|
-
<p id="login-error" className="text-sm text-destructive">
|
|
71
|
-
{error}
|
|
72
|
-
</p>
|
|
73
|
-
)}
|
|
74
|
-
<Button type="submit" disabled={loading} className="w-full">
|
|
75
|
-
{loading ? "Signing in..." : "Sign in"}
|
|
76
|
-
</Button>
|
|
77
|
-
</form>
|
|
78
|
-
<p className="text-xs text-muted-foreground text-center">Demo credentials: admin / admin</p>
|
|
79
|
-
<p className="text-xs text-muted-foreground text-center">
|
|
80
|
-
Demo only — replace with real auth before shipping.
|
|
81
|
-
</p>
|
|
82
|
-
<p className="text-center">
|
|
83
|
-
<a
|
|
84
|
-
href="/"
|
|
85
|
-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
|
86
|
-
>
|
|
87
|
-
← Back home
|
|
88
|
-
</a>
|
|
89
|
-
</p>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
}
|