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,91 +0,0 @@
|
|
|
1
|
-
import type { Database } from "bun:sqlite";
|
|
2
|
-
// DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
|
|
3
|
-
// no session expiry. This auth is a placeholder for demos — replace with real
|
|
4
|
-
// credential storage (hashed passwords) before shipping anything production.
|
|
5
|
-
import { randomUUID } from "node:crypto";
|
|
6
|
-
import { mkdirSync } from "node:fs";
|
|
7
|
-
import { dirname, join } from "node:path";
|
|
8
|
-
import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
|
|
9
|
-
|
|
10
|
-
const SESSION_COOKIE = "x_session";
|
|
11
|
-
const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
|
|
12
|
-
|
|
13
|
-
export interface Session {
|
|
14
|
-
id: string;
|
|
15
|
-
token: string;
|
|
16
|
-
user_id: string;
|
|
17
|
-
username: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let db: Database | null = null;
|
|
21
|
-
|
|
22
|
-
function getDb(): Database {
|
|
23
|
-
if (db) return db;
|
|
24
|
-
const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
|
|
25
|
-
mkdirSync(dirname(dbPath), { recursive: true });
|
|
26
|
-
db = connectSQLite({ path: dbPath });
|
|
27
|
-
runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
|
|
28
|
-
return db;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function createSession(username: string): Session {
|
|
32
|
-
const db = getDb();
|
|
33
|
-
const id = randomUUID();
|
|
34
|
-
const token = randomUUID();
|
|
35
|
-
const userId = `user_${randomUUID().slice(0, 8)}`;
|
|
36
|
-
|
|
37
|
-
db.run("INSERT INTO sessions (id, token, user_id, username) VALUES (?1, ?2, ?3, ?4)", [
|
|
38
|
-
id,
|
|
39
|
-
token,
|
|
40
|
-
userId,
|
|
41
|
-
username,
|
|
42
|
-
] as unknown as string[]);
|
|
43
|
-
|
|
44
|
-
return { id, token, user_id: userId, username };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// DEMO ONLY: the single source of truth for the credential check, shared by
|
|
48
|
-
// the login API route and the login page's server fallback. Replace this with
|
|
49
|
-
// real (hashed) password verification before shipping.
|
|
50
|
-
export function authenticate(email: string, password: string): Session | null {
|
|
51
|
-
if (email === "admin" && password === "admin") {
|
|
52
|
-
return createSession(email);
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function getSession(token: string | undefined): Session | null {
|
|
58
|
-
if (!token) return null;
|
|
59
|
-
const db = getDb();
|
|
60
|
-
const row = db
|
|
61
|
-
.prepare("SELECT id, token, user_id, username FROM sessions WHERE token = ?1")
|
|
62
|
-
.get(token) as { id: string; token: string; user_id: string; username: string } | null;
|
|
63
|
-
if (!row) return null;
|
|
64
|
-
return { id: row.id, token: row.token, user_id: row.user_id, username: row.username };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function deleteSession(token: string): void {
|
|
68
|
-
const db = getDb();
|
|
69
|
-
db.run("DELETE FROM sessions WHERE token = ?1", [token] as unknown as string[]);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function parseSessionCookie(cookieHeader: string | null): string | undefined {
|
|
73
|
-
if (!cookieHeader) return undefined;
|
|
74
|
-
for (const part of cookieHeader.split(";")) {
|
|
75
|
-
const trimmed = part.trim();
|
|
76
|
-
if (trimmed.startsWith(`${SESSION_COOKIE}=`)) {
|
|
77
|
-
return trimmed.slice(SESSION_COOKIE.length + 1);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
84
|
-
|
|
85
|
-
export function setSessionCookie(token: string): string {
|
|
86
|
-
return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export function clearSessionCookie(): string {
|
|
90
|
-
return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
|
|
91
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { MiddlewareContext, MiddlewareNext } from "@thexjs/core";
|
|
2
|
-
import { getSession, parseSessionCookie } from "../../lib/auth";
|
|
3
|
-
|
|
4
|
-
export default async function middleware(ctx: MiddlewareContext, next: MiddlewareNext) {
|
|
5
|
-
const token = parseSessionCookie(ctx.request.headers.get("Cookie"));
|
|
6
|
-
const session = getSession(token);
|
|
7
|
-
if (!session) return new Response(null, { status: 302, headers: { Location: "/login" } });
|
|
8
|
-
return next();
|
|
9
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import { BarChart3, PieChart, TrendingUp } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
export async function loader({ request }: LoaderArgs) {
|
|
5
|
-
const { parseSessionCookie, getSession } = await import("../../lib/auth");
|
|
6
|
-
const token = parseSessionCookie(request.headers.get("Cookie"));
|
|
7
|
-
const session = getSession(token);
|
|
8
|
-
return { username: session?.username ?? "User" };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const charts = [
|
|
12
|
-
{ icon: BarChart3, title: "Monthly Revenue", colors: "from-blue-500/20 to-purple-500/20" },
|
|
13
|
-
{ icon: TrendingUp, title: "User Growth", colors: "from-emerald-500/20 to-teal-500/20" },
|
|
14
|
-
{ icon: PieChart, title: "Traffic Sources", colors: "from-orange-500/20 to-pink-500/20" },
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
export default function AnalyticsPage({ loaderData }: RouteProps) {
|
|
18
|
-
return (
|
|
19
|
-
<div className="space-y-8">
|
|
20
|
-
<div>
|
|
21
|
-
<h2 className="text-2xl font-bold tracking-tight text-foreground">Analytics</h2>
|
|
22
|
-
<p className="mt-1 text-sm text-muted-foreground">Track your performance metrics</p>
|
|
23
|
-
</div>
|
|
24
|
-
|
|
25
|
-
<div className="grid gap-6 lg:grid-cols-3">
|
|
26
|
-
{charts.map((chart) => {
|
|
27
|
-
const Icon = chart.icon;
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
key={chart.title}
|
|
31
|
-
className="group rounded-2xl border border-border bg-card p-6 transition-all hover:border-primary/50 hover:shadow-lg hover:shadow-primary/5"
|
|
32
|
-
>
|
|
33
|
-
<div className="flex items-center gap-3">
|
|
34
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary transition-colors group-hover:bg-primary/20">
|
|
35
|
-
<Icon className="h-5 w-5" />
|
|
36
|
-
</div>
|
|
37
|
-
<h3 className="text-lg font-semibold text-card-foreground">{chart.title}</h3>
|
|
38
|
-
</div>
|
|
39
|
-
<div
|
|
40
|
-
className={`mt-6 flex h-48 items-center justify-center rounded-xl bg-gradient-to-br ${chart.colors} border border-border/50`}
|
|
41
|
-
>
|
|
42
|
-
<p className="text-sm text-muted-foreground">Chart placeholder</p>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
})}
|
|
47
|
-
</div>
|
|
48
|
-
|
|
49
|
-
<div className="rounded-2xl border border-border bg-card p-6">
|
|
50
|
-
<h3 className="text-lg font-semibold text-card-foreground mb-4">Summary</h3>
|
|
51
|
-
<div className="grid gap-4 sm:grid-cols-3">
|
|
52
|
-
<div className="rounded-xl border border-border bg-background p-4">
|
|
53
|
-
<p className="text-sm text-muted-foreground">Total Page Views</p>
|
|
54
|
-
<p className="mt-1 text-2xl font-bold text-foreground">1,234,567</p>
|
|
55
|
-
</div>
|
|
56
|
-
<div className="rounded-xl border border-border bg-background p-4">
|
|
57
|
-
<p className="text-sm text-muted-foreground">Conversion Rate</p>
|
|
58
|
-
<p className="mt-1 text-2xl font-bold text-foreground">3.42%</p>
|
|
59
|
-
</div>
|
|
60
|
-
<div className="rounded-xl border border-border bg-background p-4">
|
|
61
|
-
<p className="text-sm text-muted-foreground">Avg. Session</p>
|
|
62
|
-
<p className="mt-1 text-2xl font-bold text-foreground">4m 32s</p>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
</div>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import { Activity, DollarSign, TrendingUp, Users } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
export async function loader({ request }: LoaderArgs) {
|
|
5
|
-
const { parseSessionCookie, getSession } = await import("../../lib/auth");
|
|
6
|
-
const token = parseSessionCookie(request.headers.get("Cookie"));
|
|
7
|
-
const session = getSession(token);
|
|
8
|
-
return { username: session?.username ?? "User" };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const stats = [
|
|
12
|
-
{ label: "Total Users", value: "24,563", change: "+12.5%", icon: Users, trend: "up" },
|
|
13
|
-
{ label: "Revenue", value: "$48,290", change: "+8.2%", icon: DollarSign, trend: "up" },
|
|
14
|
-
{ label: "Active Now", value: "1,429", change: "+3.1%", icon: Activity, trend: "up" },
|
|
15
|
-
{ label: "Growth", value: "23.4%", change: "+2.4%", icon: TrendingUp, trend: "up" },
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
const recentActivity = [
|
|
19
|
-
{ user: "Sarah Chen", action: "created a new project", time: "2 minutes ago" },
|
|
20
|
-
{ user: "Mike Johnson", action: "upgraded to Pro plan", time: "15 minutes ago" },
|
|
21
|
-
{ user: "Emily Davis", action: "invited 3 team members", time: "1 hour ago" },
|
|
22
|
-
{ user: "Alex Kim", action: "completed onboarding", time: "3 hours ago" },
|
|
23
|
-
{ user: "Lisa Park", action: "exported analytics report", time: "5 hours ago" },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export default function DashboardPage({ loaderData }: RouteProps) {
|
|
27
|
-
return (
|
|
28
|
-
<div className="space-y-8">
|
|
29
|
-
<div>
|
|
30
|
-
<h2 className="text-2xl font-bold tracking-tight text-foreground">Dashboard</h2>
|
|
31
|
-
<p className="mt-1 text-sm text-muted-foreground">
|
|
32
|
-
Welcome back, {loaderData?.username as string}!
|
|
33
|
-
</p>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-4">
|
|
37
|
-
{stats.map((stat) => {
|
|
38
|
-
const Icon = stat.icon;
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
key={stat.label}
|
|
42
|
-
className="group rounded-2xl border border-border bg-card p-6 transition-all hover:border-primary/50 hover:shadow-lg hover:shadow-primary/5"
|
|
43
|
-
>
|
|
44
|
-
<div className="flex items-center justify-between">
|
|
45
|
-
<span className="text-sm font-medium text-muted-foreground">{stat.label}</span>
|
|
46
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary transition-colors group-hover:bg-primary/20">
|
|
47
|
-
<Icon className="h-5 w-5" />
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<p className="mt-4 text-3xl font-bold tracking-tight text-card-foreground">
|
|
51
|
-
{stat.value}
|
|
52
|
-
</p>
|
|
53
|
-
<p className="mt-1 text-sm text-emerald-400">{stat.change} this month</p>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
})}
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div className="rounded-2xl border border-border bg-card">
|
|
60
|
-
<div className="border-b border-border px-6 py-4">
|
|
61
|
-
<h3 className="text-lg font-semibold text-card-foreground">Recent Activity</h3>
|
|
62
|
-
</div>
|
|
63
|
-
<div className="divide-y divide-border">
|
|
64
|
-
{recentActivity.map((item) => (
|
|
65
|
-
<div
|
|
66
|
-
key={item.user + item.time}
|
|
67
|
-
className="flex items-center justify-between px-6 py-4"
|
|
68
|
-
>
|
|
69
|
-
<div className="flex items-center gap-3">
|
|
70
|
-
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">
|
|
71
|
-
{item.user.charAt(0)}
|
|
72
|
-
</div>
|
|
73
|
-
<div>
|
|
74
|
-
<p className="text-sm text-card-foreground">
|
|
75
|
-
<span className="font-medium">{item.user}</span> {item.action}
|
|
76
|
-
</p>
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
<span className="text-xs text-muted-foreground">{item.time}</span>
|
|
80
|
-
</div>
|
|
81
|
-
))}
|
|
82
|
-
</div>
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import { AlertTriangle, Bell, Save, User } from "lucide-react";
|
|
3
|
-
|
|
4
|
-
export async function loader({ request }: LoaderArgs) {
|
|
5
|
-
const { parseSessionCookie, getSession } = await import("../../lib/auth");
|
|
6
|
-
const token = parseSessionCookie(request.headers.get("Cookie"));
|
|
7
|
-
const session = getSession(token);
|
|
8
|
-
return { username: session?.username ?? "User" };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default function SettingsPage({ loaderData }: RouteProps) {
|
|
12
|
-
return (
|
|
13
|
-
<div className="space-y-8">
|
|
14
|
-
<div>
|
|
15
|
-
<h2 className="text-2xl font-bold tracking-tight text-foreground">Settings</h2>
|
|
16
|
-
<p className="mt-1 text-sm text-muted-foreground">Manage your account settings</p>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<div className="rounded-2xl border border-border bg-card">
|
|
20
|
-
<div className="flex items-center gap-3 border-b border-border px-6 py-4">
|
|
21
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
22
|
-
<User className="h-5 w-5" />
|
|
23
|
-
</div>
|
|
24
|
-
<h3 className="text-lg font-semibold text-card-foreground">Profile</h3>
|
|
25
|
-
</div>
|
|
26
|
-
<div className="space-y-5 p-6">
|
|
27
|
-
<div className="grid gap-5 sm:grid-cols-2">
|
|
28
|
-
<div>
|
|
29
|
-
<label
|
|
30
|
-
htmlFor="name"
|
|
31
|
-
className="block text-sm font-medium text-card-foreground mb-1.5"
|
|
32
|
-
>
|
|
33
|
-
Name
|
|
34
|
-
</label>
|
|
35
|
-
<input
|
|
36
|
-
id="name"
|
|
37
|
-
defaultValue={loaderData?.username as string}
|
|
38
|
-
className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
<div>
|
|
42
|
-
<label
|
|
43
|
-
htmlFor="settings-email"
|
|
44
|
-
className="block text-sm font-medium text-card-foreground mb-1.5"
|
|
45
|
-
>
|
|
46
|
-
Email
|
|
47
|
-
</label>
|
|
48
|
-
<input
|
|
49
|
-
id="settings-email"
|
|
50
|
-
type="email"
|
|
51
|
-
defaultValue="john@example.com"
|
|
52
|
-
className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
<button
|
|
57
|
-
type="button"
|
|
58
|
-
className="inline-flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90"
|
|
59
|
-
>
|
|
60
|
-
<Save className="h-4 w-4" />
|
|
61
|
-
Save Changes
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<div className="rounded-2xl border border-border bg-card">
|
|
67
|
-
<div className="flex items-center gap-3 border-b border-border px-6 py-4">
|
|
68
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
69
|
-
<Bell className="h-5 w-5" />
|
|
70
|
-
</div>
|
|
71
|
-
<h3 className="text-lg font-semibold text-card-foreground">Notifications</h3>
|
|
72
|
-
</div>
|
|
73
|
-
<div className="space-y-4 p-6">
|
|
74
|
-
{["Email notifications", "Push notifications", "Weekly digest", "Product updates"].map(
|
|
75
|
-
(item) => (
|
|
76
|
-
<div
|
|
77
|
-
key={item}
|
|
78
|
-
className="flex items-center justify-between rounded-xl border border-border bg-background px-4 py-3"
|
|
79
|
-
>
|
|
80
|
-
<span className="text-sm text-card-foreground">{item}</span>
|
|
81
|
-
<div className="flex h-6 w-11 cursor-pointer items-center rounded-full bg-primary p-0.5 transition-colors">
|
|
82
|
-
<div className="h-5 w-5 rounded-full bg-white shadow-sm transition-transform translate-x-[1.25rem]" />
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
),
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
|
|
90
|
-
<div className="rounded-2xl border border-destructive/30 bg-card">
|
|
91
|
-
<div className="flex items-center gap-3 border-b border-border px-6 py-4">
|
|
92
|
-
<div className="flex h-10 w-10 items-center justify-center rounded-xl bg-destructive/10 text-destructive">
|
|
93
|
-
<AlertTriangle className="h-5 w-5" />
|
|
94
|
-
</div>
|
|
95
|
-
<h3 className="text-lg font-semibold text-card-foreground">Danger Zone</h3>
|
|
96
|
-
</div>
|
|
97
|
-
<div className="p-6">
|
|
98
|
-
<p className="text-sm text-muted-foreground mb-4">
|
|
99
|
-
Permanently delete your account and all associated data.
|
|
100
|
-
</p>
|
|
101
|
-
<button
|
|
102
|
-
type="button"
|
|
103
|
-
className="rounded-xl border border-destructive/50 bg-destructive/10 px-5 py-2.5 text-sm font-semibold text-destructive transition-all hover:bg-destructive/20"
|
|
104
|
-
>
|
|
105
|
-
Delete Account
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { ArrowRight, BarChart3, Globe, Lock, Shield, Users, Zap } from "lucide-react";
|
|
2
|
-
import { cn } from "../lib/utils";
|
|
3
|
-
|
|
4
|
-
const features = [
|
|
5
|
-
{
|
|
6
|
-
icon: Zap,
|
|
7
|
-
title: "Lightning Fast",
|
|
8
|
-
description: "Blazing performance with edge-ready infrastructure.",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
icon: Shield,
|
|
12
|
-
title: "Enterprise Security",
|
|
13
|
-
description: "Bank-grade encryption and compliance built-in.",
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
icon: BarChart3,
|
|
17
|
-
title: "Advanced Analytics",
|
|
18
|
-
description: "Real-time insights with customizable dashboards.",
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
icon: Users,
|
|
22
|
-
title: "Team Collaboration",
|
|
23
|
-
description: "Work together seamlessly in real-time.",
|
|
24
|
-
},
|
|
25
|
-
{ icon: Globe, title: "Global Scale", description: "Deploy to 30+ regions worldwide." },
|
|
26
|
-
{ icon: Lock, title: "Access Control", description: "Granular permissions and SSO integration." },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
export default function HomePage() {
|
|
30
|
-
return (
|
|
31
|
-
<div className="bg-background">
|
|
32
|
-
<section className="relative overflow-hidden px-4 pb-24 pt-20 sm:px-6 lg:px-8">
|
|
33
|
-
<div className="mx-auto max-w-7xl text-center">
|
|
34
|
-
<h1 className="bg-gradient-to-r from-foreground via-primary to-chart-1 bg-clip-text text-5xl font-bold tracking-tight text-transparent sm:text-6xl lg:text-7xl">
|
|
35
|
-
Your All-in-One Platform
|
|
36
|
-
</h1>
|
|
37
|
-
<p className="mx-auto mt-6 max-w-2xl text-lg text-muted-foreground">
|
|
38
|
-
Build, deploy, and scale your SaaS application with modern tools, real-time analytics,
|
|
39
|
-
and enterprise-grade security.
|
|
40
|
-
</p>
|
|
41
|
-
<div className="mt-10 flex items-center justify-center gap-4">
|
|
42
|
-
<a
|
|
43
|
-
href="/pricing"
|
|
44
|
-
className="inline-flex items-center gap-2 rounded-xl bg-primary px-6 py-3 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/30"
|
|
45
|
-
>
|
|
46
|
-
Get Started
|
|
47
|
-
<ArrowRight className="h-4 w-4" />
|
|
48
|
-
</a>
|
|
49
|
-
<a
|
|
50
|
-
href="/login"
|
|
51
|
-
className="inline-flex items-center gap-2 rounded-xl border border-border bg-background px-6 py-3 text-sm font-semibold text-foreground transition-all hover:bg-muted"
|
|
52
|
-
>
|
|
53
|
-
Sign In
|
|
54
|
-
</a>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
</section>
|
|
58
|
-
|
|
59
|
-
<section id="features" className="border-t border-border px-4 py-24 sm:px-6 lg:px-8">
|
|
60
|
-
<div className="mx-auto max-w-7xl">
|
|
61
|
-
<div className="text-center">
|
|
62
|
-
<h2 className="text-3xl font-bold tracking-tight text-foreground sm:text-4xl">
|
|
63
|
-
Everything you need
|
|
64
|
-
</h2>
|
|
65
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
66
|
-
Powerful features to help you scale your business.
|
|
67
|
-
</p>
|
|
68
|
-
</div>
|
|
69
|
-
<div className="mt-16 grid gap-8 sm:grid-cols-2 lg:grid-cols-3">
|
|
70
|
-
{features.map((feature) => {
|
|
71
|
-
const Icon = feature.icon;
|
|
72
|
-
return (
|
|
73
|
-
<div
|
|
74
|
-
key={feature.title}
|
|
75
|
-
className="group rounded-2xl border border-border bg-card p-6 transition-all hover:border-primary/50 hover:shadow-lg hover:shadow-primary/5"
|
|
76
|
-
>
|
|
77
|
-
<div className="flex h-12 w-12 items-center justify-center rounded-xl bg-primary/10 text-primary transition-colors group-hover:bg-primary/20">
|
|
78
|
-
<Icon className="h-6 w-6" />
|
|
79
|
-
</div>
|
|
80
|
-
<h3 className="mt-4 text-lg font-semibold text-card-foreground">
|
|
81
|
-
{feature.title}
|
|
82
|
-
</h3>
|
|
83
|
-
<p className="mt-2 text-sm text-muted-foreground">{feature.description}</p>
|
|
84
|
-
</div>
|
|
85
|
-
);
|
|
86
|
-
})}
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</section>
|
|
90
|
-
|
|
91
|
-
<section className="border-t border-border px-4 py-24 sm:px-6 lg:px-8">
|
|
92
|
-
<div className="mx-auto max-w-4xl text-center">
|
|
93
|
-
<h2 className="text-3xl font-bold tracking-tight text-foreground sm:text-4xl">
|
|
94
|
-
Ready to get started?
|
|
95
|
-
</h2>
|
|
96
|
-
<p className="mt-4 text-lg text-muted-foreground">
|
|
97
|
-
Join thousands of teams already building with SaaS.
|
|
98
|
-
</p>
|
|
99
|
-
<a
|
|
100
|
-
href="/pricing"
|
|
101
|
-
className="mt-8 inline-flex items-center gap-2 rounded-xl bg-primary px-8 py-4 text-base font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/30"
|
|
102
|
-
>
|
|
103
|
-
Start your free trial
|
|
104
|
-
<ArrowRight className="h-5 w-5" />
|
|
105
|
-
</a>
|
|
106
|
-
</div>
|
|
107
|
-
</section>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { LoaderArgs, RouteProps } from "@thexjs/core";
|
|
2
|
-
import { LogIn } from "lucide-react";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { Button } from "../components/ui/button";
|
|
5
|
-
import { Input } from "../components/ui/input";
|
|
6
|
-
import { authenticate, setSessionCookie } from "../lib/auth";
|
|
7
|
-
import { cn } from "../lib/utils";
|
|
8
|
-
|
|
9
|
-
export async function loader({ request }: LoaderArgs) {
|
|
10
|
-
if (request.method === "POST") {
|
|
11
|
-
const formData = await request.formData();
|
|
12
|
-
const username = formData.get("email") as string | null;
|
|
13
|
-
const password = formData.get("password") as string | null;
|
|
14
|
-
const session = username && password ? authenticate(username, password) : null;
|
|
15
|
-
if (session) {
|
|
16
|
-
return new Response(null, {
|
|
17
|
-
status: 302,
|
|
18
|
-
headers: { Location: "/dashboard", "Set-Cookie": setSessionCookie(session.token) },
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return { error: "Invalid credentials" };
|
|
22
|
-
}
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function LoginPage({ loaderData }: RouteProps) {
|
|
27
|
-
const [error, setError] = useState((loaderData?.error as string) ?? "");
|
|
28
|
-
const [loading, setLoading] = useState(false);
|
|
29
|
-
|
|
30
|
-
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
|
31
|
-
e.preventDefault();
|
|
32
|
-
setError("");
|
|
33
|
-
setLoading(true);
|
|
34
|
-
const form = e.currentTarget;
|
|
35
|
-
const data = {
|
|
36
|
-
email: (form.elements.namedItem("email") as HTMLInputElement).value,
|
|
37
|
-
password: (form.elements.namedItem("password") as HTMLInputElement).value,
|
|
38
|
-
};
|
|
39
|
-
try {
|
|
40
|
-
const res = await fetch("/api/auth/login", {
|
|
41
|
-
method: "POST",
|
|
42
|
-
headers: { "Content-Type": "application/json" },
|
|
43
|
-
body: JSON.stringify(data),
|
|
44
|
-
});
|
|
45
|
-
if (res.ok) {
|
|
46
|
-
window.location.href = "/dashboard";
|
|
47
|
-
} else {
|
|
48
|
-
const err = (await res.json()) as { error?: string };
|
|
49
|
-
setError(err.error || "Login failed");
|
|
50
|
-
}
|
|
51
|
-
} catch {
|
|
52
|
-
setError("Network error");
|
|
53
|
-
} finally {
|
|
54
|
-
setLoading(false);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<div className="flex min-h-[calc(100vh-4rem)] items-center justify-center px-4">
|
|
60
|
-
<div className="w-full max-w-sm">
|
|
61
|
-
<div className="rounded-2xl border border-border bg-card p-8 shadow-xl shadow-black/10">
|
|
62
|
-
<div className="mb-8 text-center">
|
|
63
|
-
<div className="mx-auto flex h-12 w-12 items-center justify-center rounded-xl bg-primary/10 text-primary">
|
|
64
|
-
<LogIn className="h-6 w-6" />
|
|
65
|
-
</div>
|
|
66
|
-
<h1 className="mt-4 text-2xl font-bold tracking-tight text-card-foreground">
|
|
67
|
-
Welcome back
|
|
68
|
-
</h1>
|
|
69
|
-
<p className="mt-2 text-sm text-muted-foreground">Sign in to your account</p>
|
|
70
|
-
</div>
|
|
71
|
-
<form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-5">
|
|
72
|
-
<div>
|
|
73
|
-
<label
|
|
74
|
-
htmlFor="email"
|
|
75
|
-
className="block text-sm font-medium text-card-foreground mb-1.5"
|
|
76
|
-
>
|
|
77
|
-
Email
|
|
78
|
-
</label>
|
|
79
|
-
<Input
|
|
80
|
-
id="email"
|
|
81
|
-
name="email"
|
|
82
|
-
type="email"
|
|
83
|
-
defaultValue="admin"
|
|
84
|
-
placeholder="you@example.com"
|
|
85
|
-
className={cn(
|
|
86
|
-
"h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground",
|
|
87
|
-
)}
|
|
88
|
-
required
|
|
89
|
-
/>
|
|
90
|
-
</div>
|
|
91
|
-
<div>
|
|
92
|
-
<label
|
|
93
|
-
htmlFor="password"
|
|
94
|
-
className="block text-sm font-medium text-card-foreground mb-1.5"
|
|
95
|
-
>
|
|
96
|
-
Password
|
|
97
|
-
</label>
|
|
98
|
-
<Input
|
|
99
|
-
id="password"
|
|
100
|
-
name="password"
|
|
101
|
-
type="password"
|
|
102
|
-
defaultValue="admin"
|
|
103
|
-
placeholder="••••••••"
|
|
104
|
-
className="h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground"
|
|
105
|
-
required
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
{error && (
|
|
109
|
-
<p id="login-error" className="text-sm text-destructive">
|
|
110
|
-
{error}
|
|
111
|
-
</p>
|
|
112
|
-
)}
|
|
113
|
-
<Button
|
|
114
|
-
type="submit"
|
|
115
|
-
disabled={loading}
|
|
116
|
-
className="h-10 w-full rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/25"
|
|
117
|
-
>
|
|
118
|
-
{loading ? "Signing in..." : "Sign in"}
|
|
119
|
-
</Button>
|
|
120
|
-
</form>
|
|
121
|
-
<p className="mt-4 text-center text-xs text-muted-foreground">
|
|
122
|
-
Demo credentials: <code className="text-foreground">admin / admin</code>
|
|
123
|
-
</p>
|
|
124
|
-
<p className="mt-1 text-center text-[11px] text-muted-foreground">
|
|
125
|
-
Demo only — replace with real auth before shipping.
|
|
126
|
-
</p>
|
|
127
|
-
<p className="mt-6 text-center text-sm text-muted-foreground">
|
|
128
|
-
Don't have an account?{" "}
|
|
129
|
-
<a
|
|
130
|
-
href="/login"
|
|
131
|
-
className="font-medium text-foreground underline underline-offset-4 hover:text-primary transition-colors"
|
|
132
|
-
>
|
|
133
|
-
Register
|
|
134
|
-
</a>
|
|
135
|
-
</p>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
}
|