create-thexjs-app 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +56 -915
  2. package/dist/index.js +283 -196
  3. package/package.json +5 -1
  4. package/templates/{basic → addons/auth}/src/api/auth/login.ts +1 -3
  5. package/templates/{basic → addons/auth}/src/lib/auth.ts +13 -9
  6. package/templates/{basic → addons/auth}/src/lib/migrations/001_create_sessions.sql +1 -3
  7. package/templates/addons/auth/src/pages/dashboard/index.tsx +39 -0
  8. package/templates/addons/auth/src/pages/login.tsx +72 -0
  9. package/templates/addons/content/content/hello-world.md +13 -0
  10. package/templates/addons/content/src/pages/blog.tsx +29 -0
  11. package/templates/{basic → addons/shadcn}/components.json +1 -1
  12. package/templates/addons/shadcn/src/components/ui/badge.tsx +17 -0
  13. package/templates/addons/shadcn/src/components/ui/button.tsx +36 -0
  14. package/templates/addons/shadcn/src/components/ui/card.tsx +33 -0
  15. package/templates/addons/shadcn/src/components/ui/input.tsx +18 -0
  16. package/templates/addons/tailwind/src/styles/globals.css +32 -0
  17. package/templates/base/_gitignore +26 -0
  18. package/templates/base/src/pages/index.tsx +29 -0
  19. package/templates/base/src/styles/globals.css +22 -0
  20. package/templates/base/tsconfig.json +24 -0
  21. package/templates/basic/content/blog/hello.md +0 -8
  22. package/templates/basic/public/favicon.ico +0 -0
  23. package/templates/basic/src/actions/dashboard/greet.ts +0 -3
  24. package/templates/basic/src/api/placeholder/comments.ts +0 -17
  25. package/templates/basic/src/api/placeholder/posts.ts +0 -20
  26. package/templates/basic/src/api/placeholder/todos.ts +0 -21
  27. package/templates/basic/src/api/placeholder/users.ts +0 -12
  28. package/templates/basic/src/components/Head.tsx +0 -21
  29. package/templates/basic/src/components/Image.tsx +0 -27
  30. package/templates/basic/src/components/Link.tsx +0 -10
  31. package/templates/basic/src/components/ui/badge.tsx +0 -49
  32. package/templates/basic/src/components/ui/button.tsx +0 -58
  33. package/templates/basic/src/components/ui/card.tsx +0 -88
  34. package/templates/basic/src/components/ui/input.tsx +0 -20
  35. package/templates/basic/src/layouts/main.tsx +0 -38
  36. package/templates/basic/src/lib/placeholder-data.ts +0 -176
  37. package/templates/basic/src/pages/_404.tsx +0 -17
  38. package/templates/basic/src/pages/about.tsx +0 -22
  39. package/templates/basic/src/pages/blog.tsx +0 -41
  40. package/templates/basic/src/pages/dashboard/index.tsx +0 -84
  41. package/templates/basic/src/pages/index.tsx +0 -54
  42. package/templates/basic/src/pages/login.tsx +0 -92
  43. package/templates/basic/src/pages/placeholder.tsx +0 -203
  44. package/templates/basic/src/pages/posts/[id].tsx +0 -17
  45. package/templates/basic/src/styles/globals.css +0 -90
  46. package/templates/basic/src/x-routes.ts +0 -29
  47. package/templates/basic/tsconfig.json +0 -11
  48. package/templates/basic/x.config.ts +0 -10
  49. package/templates/blog/components.json +0 -20
  50. package/templates/blog/content/posts/getting-started.md +0 -38
  51. package/templates/blog/content/posts/hello-world.md +0 -21
  52. package/templates/blog/content/posts/tailwind-v4.md +0 -31
  53. package/templates/blog/public/favicon.ico +0 -0
  54. package/templates/blog/src/components/ui/avatar.tsx +0 -91
  55. package/templates/blog/src/components/ui/badge.tsx +0 -49
  56. package/templates/blog/src/components/ui/button.tsx +0 -58
  57. package/templates/blog/src/components/ui/card.tsx +0 -88
  58. package/templates/blog/src/components/ui/input.tsx +0 -20
  59. package/templates/blog/src/layouts/blog.tsx +0 -46
  60. package/templates/blog/src/layouts/main.tsx +0 -32
  61. package/templates/blog/src/lib/utils.ts +0 -5
  62. package/templates/blog/src/pages/about.tsx +0 -36
  63. package/templates/blog/src/pages/blog/[slug].tsx +0 -56
  64. package/templates/blog/src/pages/blog/index.tsx +0 -70
  65. package/templates/blog/src/pages/index.tsx +0 -73
  66. package/templates/blog/src/styles/globals.css +0 -90
  67. package/templates/blog/src/x-routes.ts +0 -20
  68. package/templates/blog/tsconfig.json +0 -5
  69. package/templates/blog/x.config.ts +0 -6
  70. package/templates/default/components.json +0 -19
  71. package/templates/default/src/layouts/main.tsx +0 -28
  72. package/templates/default/src/pages/index.tsx +0 -66
  73. package/templates/default/src/styles/globals.css +0 -55
  74. package/templates/default/src/x-routes.ts +0 -17
  75. package/templates/default/tsconfig.json +0 -5
  76. package/templates/default/x.config.ts +0 -6
  77. package/templates/landing/components.json +0 -20
  78. package/templates/landing/public/favicon.ico +0 -0
  79. package/templates/landing/src/components/code-block.tsx +0 -118
  80. package/templates/landing/src/components/ui/avatar.tsx +0 -91
  81. package/templates/landing/src/components/ui/badge.tsx +0 -49
  82. package/templates/landing/src/components/ui/button.tsx +0 -58
  83. package/templates/landing/src/components/ui/card.tsx +0 -88
  84. package/templates/landing/src/components/ui/input.tsx +0 -20
  85. package/templates/landing/src/layouts/main.tsx +0 -78
  86. package/templates/landing/src/lib/syntax.tsx +0 -366
  87. package/templates/landing/src/lib/utils.ts +0 -5
  88. package/templates/landing/src/pages/docs/_layout.tsx +0 -139
  89. package/templates/landing/src/pages/docs/api-routes.tsx +0 -113
  90. package/templates/landing/src/pages/docs/build-deploy.tsx +0 -124
  91. package/templates/landing/src/pages/docs/configuration.tsx +0 -121
  92. package/templates/landing/src/pages/docs/content-collections.tsx +0 -130
  93. package/templates/landing/src/pages/docs/data-layer.tsx +0 -142
  94. package/templates/landing/src/pages/docs/getting-started.tsx +0 -129
  95. package/templates/landing/src/pages/docs/index.tsx +0 -187
  96. package/templates/landing/src/pages/docs/installation.tsx +0 -143
  97. package/templates/landing/src/pages/docs/introduction.tsx +0 -114
  98. package/templates/landing/src/pages/docs/layouts.tsx +0 -114
  99. package/templates/landing/src/pages/docs/middleware.tsx +0 -124
  100. package/templates/landing/src/pages/docs/packages/cli.tsx +0 -133
  101. package/templates/landing/src/pages/docs/packages/core.tsx +0 -176
  102. package/templates/landing/src/pages/docs/packages/env.tsx +0 -128
  103. package/templates/landing/src/pages/docs/pages.tsx +0 -135
  104. package/templates/landing/src/pages/docs/routing.tsx +0 -123
  105. package/templates/landing/src/pages/docs/server-functions.tsx +0 -177
  106. package/templates/landing/src/pages/features.tsx +0 -129
  107. package/templates/landing/src/pages/index.tsx +0 -159
  108. package/templates/landing/src/styles/globals.css +0 -136
  109. package/templates/landing/src/x-routes.ts +0 -31
  110. package/templates/landing/tsconfig.json +0 -10
  111. package/templates/landing/x.config.ts +0 -2
  112. package/templates/saas/components.json +0 -20
  113. package/templates/saas/public/favicon.ico +0 -0
  114. package/templates/saas/src/actions/dashboard.ts +0 -3
  115. package/templates/saas/src/api/auth/login.ts +0 -31
  116. package/templates/saas/src/components/ui/avatar.tsx +0 -91
  117. package/templates/saas/src/components/ui/badge.tsx +0 -49
  118. package/templates/saas/src/components/ui/button.tsx +0 -58
  119. package/templates/saas/src/components/ui/card.tsx +0 -88
  120. package/templates/saas/src/components/ui/input.tsx +0 -20
  121. package/templates/saas/src/layouts/dashboard.tsx +0 -67
  122. package/templates/saas/src/layouts/main.tsx +0 -38
  123. package/templates/saas/src/lib/auth.ts +0 -91
  124. package/templates/saas/src/lib/migrations/001_create_sessions.sql +0 -9
  125. package/templates/saas/src/lib/utils.ts +0 -5
  126. package/templates/saas/src/pages/dashboard/_middleware.ts +0 -9
  127. package/templates/saas/src/pages/dashboard/analytics.tsx +0 -68
  128. package/templates/saas/src/pages/dashboard/index.tsx +0 -86
  129. package/templates/saas/src/pages/dashboard/settings.tsx +0 -111
  130. package/templates/saas/src/pages/index.tsx +0 -110
  131. package/templates/saas/src/pages/login.tsx +0 -140
  132. package/templates/saas/src/pages/pricing.tsx +0 -121
  133. package/templates/saas/src/styles/globals.css +0 -90
  134. package/templates/saas/src/x-routes.ts +0 -22
  135. package/templates/saas/tsconfig.json +0 -5
  136. package/templates/saas/x.config.ts +0 -7
  137. /package/templates/{basic → addons/auth}/src/api/auth/logout.ts +0 -0
  138. /package/templates/{basic → addons/auth}/src/pages/dashboard/_middleware.ts +0 -0
  139. /package/templates/{basic → addons/shadcn}/src/lib/utils.ts +0 -0
@@ -1,58 +0,0 @@
1
- import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
- import { type VariantProps, cva } from "class-variance-authority";
3
-
4
- import { cn } from "@/lib/utils";
5
-
6
- const buttonVariants = cva(
7
- "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
- {
9
- variants: {
10
- variant: {
11
- default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
- outline:
13
- "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
- secondary:
15
- "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
- ghost:
17
- "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
- destructive:
19
- "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
20
- link: "text-primary underline-offset-4 hover:underline",
21
- },
22
- size: {
23
- default:
24
- "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
25
- xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
26
- sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
27
- lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
28
- icon: "size-8",
29
- "icon-xs":
30
- "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
31
- "icon-sm":
32
- "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
33
- "icon-lg": "size-9",
34
- },
35
- },
36
- defaultVariants: {
37
- variant: "default",
38
- size: "default",
39
- },
40
- },
41
- );
42
-
43
- function Button({
44
- className,
45
- variant = "default",
46
- size = "default",
47
- ...props
48
- }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
49
- return (
50
- <ButtonPrimitive
51
- data-slot="button"
52
- className={cn(buttonVariants({ variant, size, className }))}
53
- {...props}
54
- />
55
- );
56
- }
57
-
58
- export { Button, buttonVariants };
@@ -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
- &larr; 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
- &larr; 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
- &larr; 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
- }