create-mohit-next 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +139 -2
  2. package/index.js +399 -0
  3. package/lib/features.js +358 -0
  4. package/lib/scaffold.js +471 -0
  5. package/package.json +40 -4
  6. package/templates/common/_editorconfig +12 -0
  7. package/templates/common/_gitattributes +5 -0
  8. package/templates/common/_github/dependabot.yml +14 -0
  9. package/templates/common/_github/workflows/ci.yml +66 -0
  10. package/templates/common/_husky/commit-msg +1 -0
  11. package/templates/common/_husky/pre-commit +1 -0
  12. package/templates/common/_nvmrc +1 -0
  13. package/templates/common/_prettierignore +15 -0
  14. package/templates/common/commitlint.config.mjs +10 -0
  15. package/templates/next/AGENTS.md +9 -0
  16. package/templates/next/Dockerfile +48 -0
  17. package/templates/next/README.md +328 -0
  18. package/templates/next/_dockerignore +13 -0
  19. package/templates/next/_env.example +20 -0
  20. package/templates/next/_gitignore +50 -0
  21. package/templates/next/docker-compose.yml +33 -0
  22. package/templates/next/e2e/rbac.spec.ts +69 -0
  23. package/templates/next/e2e/server.mjs +35 -0
  24. package/templates/next/eslint.config.mjs +33 -0
  25. package/templates/next/next.config.ts +47 -0
  26. package/templates/next/package.json +68 -0
  27. package/templates/next/playwright.config.ts +30 -0
  28. package/templates/next/public/robots.txt +6 -0
  29. package/templates/next/scripts/seed.ts +111 -0
  30. package/templates/next/src/app/(app)/admin/audit/page.tsx +99 -0
  31. package/templates/next/src/app/(app)/admin/page.tsx +92 -0
  32. package/templates/next/src/app/(app)/dashboard/page.tsx +120 -0
  33. package/templates/next/src/app/(app)/error.tsx +28 -0
  34. package/templates/next/src/app/(app)/layout.tsx +58 -0
  35. package/templates/next/src/app/(app)/loading.tsx +5 -0
  36. package/templates/next/src/app/(app)/reports/page.tsx +128 -0
  37. package/templates/next/src/app/(app)/settings/page.tsx +66 -0
  38. package/templates/next/src/app/(auth)/forgot-password/page.tsx +17 -0
  39. package/templates/next/src/app/(auth)/layout.tsx +18 -0
  40. package/templates/next/src/app/(auth)/login/page.tsx +18 -0
  41. package/templates/next/src/app/(auth)/register/page.tsx +18 -0
  42. package/templates/next/src/app/(auth)/reset-password/page.tsx +18 -0
  43. package/templates/next/src/app/api/account/password/route.ts +45 -0
  44. package/templates/next/src/app/api/account/route.ts +25 -0
  45. package/templates/next/src/app/api/account/sessions/route.ts +12 -0
  46. package/templates/next/src/app/api/admin/audit/route.ts +13 -0
  47. package/templates/next/src/app/api/admin/users/[id]/route.ts +61 -0
  48. package/templates/next/src/app/api/admin/users/route.ts +18 -0
  49. package/templates/next/src/app/api/auth/forgot-password/route.ts +47 -0
  50. package/templates/next/src/app/api/auth/login/route.ts +43 -0
  51. package/templates/next/src/app/api/auth/logout/route.ts +21 -0
  52. package/templates/next/src/app/api/auth/me/route.ts +21 -0
  53. package/templates/next/src/app/api/auth/register/route.ts +74 -0
  54. package/templates/next/src/app/api/auth/resend-verification/route.ts +25 -0
  55. package/templates/next/src/app/api/auth/reset-password/route.ts +43 -0
  56. package/templates/next/src/app/api/auth/verify-email/route.ts +29 -0
  57. package/templates/next/src/app/api/health/route.ts +27 -0
  58. package/templates/next/src/app/favicon.ico +0 -0
  59. package/templates/next/src/app/forbidden/page.tsx +47 -0
  60. package/templates/next/src/app/layout.tsx +55 -0
  61. package/templates/next/src/app/not-found.tsx +20 -0
  62. package/templates/next/src/app/opengraph-image.tsx +49 -0
  63. package/templates/next/src/app/page.tsx +165 -0
  64. package/templates/next/src/app/robots.ts +15 -0
  65. package/templates/next/src/app/sitemap.ts +13 -0
  66. package/templates/next/src/app/verify-email/page.tsx +23 -0
  67. package/templates/next/src/components/admin/user-actions.tsx +124 -0
  68. package/templates/next/src/components/admin/users-data-table.tsx +221 -0
  69. package/templates/next/src/components/admin/users-table.tsx +67 -0
  70. package/templates/next/src/components/auth/auth-card.tsx +41 -0
  71. package/templates/next/src/components/auth/can.tsx +34 -0
  72. package/templates/next/src/components/auth/forgot-password-form.tsx +76 -0
  73. package/templates/next/src/components/auth/form-field.tsx +40 -0
  74. package/templates/next/src/components/auth/login-form.tsx +87 -0
  75. package/templates/next/src/components/auth/password-input.tsx +43 -0
  76. package/templates/next/src/components/auth/register-form.tsx +117 -0
  77. package/templates/next/src/components/auth/reset-password-form.tsx +80 -0
  78. package/templates/next/src/components/auth/session-refresher.tsx +44 -0
  79. package/templates/next/src/components/auth/verify-email-banner.tsx +43 -0
  80. package/templates/next/src/components/auth/verify-email-status.tsx +44 -0
  81. package/templates/next/src/components/layout/nav-links.tsx +37 -0
  82. package/templates/next/src/components/layout/navbar.tsx +27 -0
  83. package/templates/next/src/components/layout/page-header.tsx +21 -0
  84. package/templates/next/src/components/layout/sidebar.tsx +83 -0
  85. package/templates/next/src/components/layout/skeletons.tsx +57 -0
  86. package/templates/next/src/components/layout/user-menu.tsx +118 -0
  87. package/templates/next/src/components/logo.tsx +16 -0
  88. package/templates/next/src/components/motion/fade-in.tsx +19 -0
  89. package/templates/next/src/components/providers/user-provider.tsx +60 -0
  90. package/templates/next/src/components/reports/animated-bar.tsx +24 -0
  91. package/templates/next/src/components/reports/role-chart.tsx +61 -0
  92. package/templates/next/src/components/reports/signups-chart.tsx +64 -0
  93. package/templates/next/src/components/role-badge.tsx +11 -0
  94. package/templates/next/src/components/settings/password-form.tsx +80 -0
  95. package/templates/next/src/components/settings/profile-form.tsx +63 -0
  96. package/templates/next/src/components/settings/sessions-card.tsx +70 -0
  97. package/templates/next/src/components/theme-toggle.tsx +61 -0
  98. package/templates/next/src/config/rbac.test.ts +89 -0
  99. package/templates/next/src/config/rbac.ts +170 -0
  100. package/templates/next/src/config/site.ts +4 -0
  101. package/templates/next/src/lib/api.ts +179 -0
  102. package/templates/next/src/lib/audit.ts +66 -0
  103. package/templates/next/src/lib/auth.ts +50 -0
  104. package/templates/next/src/lib/dal.ts +63 -0
  105. package/templates/next/src/lib/db.ts +35 -0
  106. package/templates/next/src/lib/email-templates.ts +55 -0
  107. package/templates/next/src/lib/email.ts +53 -0
  108. package/templates/next/src/lib/env.ts +90 -0
  109. package/templates/next/src/lib/http.ts +57 -0
  110. package/templates/next/src/lib/password-strength.test.ts +20 -0
  111. package/templates/next/src/lib/password-strength.ts +24 -0
  112. package/templates/next/src/lib/rate-limit.test.ts +47 -0
  113. package/templates/next/src/lib/rate-limit.ts +70 -0
  114. package/templates/next/src/lib/redirect.test.ts +23 -0
  115. package/templates/next/src/lib/redirect.ts +21 -0
  116. package/templates/next/src/lib/session.ts +71 -0
  117. package/templates/next/src/lib/theme.ts +32 -0
  118. package/templates/next/src/lib/tokens.ts +63 -0
  119. package/templates/next/src/lib/users.ts +196 -0
  120. package/templates/next/src/lib/validations/account.ts +20 -0
  121. package/templates/next/src/lib/validations/auth.test.ts +39 -0
  122. package/templates/next/src/lib/validations/auth.ts +66 -0
  123. package/templates/next/src/lib/validations/user.ts +13 -0
  124. package/templates/next/src/models/audit-log.ts +33 -0
  125. package/templates/next/src/models/auth-token.ts +26 -0
  126. package/templates/next/src/models/user.ts +35 -0
  127. package/templates/next/src/proxy.ts +57 -0
  128. package/templates/next/src/styles/app.css +1092 -0
  129. package/templates/next/src/types/user.ts +13 -0
  130. package/templates/next/tsconfig.json +34 -0
  131. package/templates/next/vitest.config.mts +13 -0
  132. package/templates/styles/css.css +580 -0
  133. package/templates/styles/shadcn.css +142 -0
  134. package/templates/styles/tailwind.css +140 -0
  135. package/templates/ui/css/components/alert-dialog.tsx +172 -0
  136. package/templates/ui/css/components/avatar.tsx +17 -0
  137. package/templates/ui/css/components/badge.tsx +18 -0
  138. package/templates/ui/css/components/button.tsx +41 -0
  139. package/templates/ui/css/components/card.tsx +33 -0
  140. package/templates/ui/css/components/dropdown-menu.tsx +230 -0
  141. package/templates/ui/css/components/input.tsx +7 -0
  142. package/templates/ui/css/components/label.tsx +7 -0
  143. package/templates/ui/css/components/native-select.tsx +23 -0
  144. package/templates/ui/css/components/skeleton.tsx +7 -0
  145. package/templates/ui/css/components/slot.tsx +30 -0
  146. package/templates/ui/css/components/table.tsx +31 -0
  147. package/templates/ui/css/utils.ts +16 -0
  148. package/templates/ui/shadcn/components/alert-dialog.tsx +199 -0
  149. package/templates/ui/shadcn/components/avatar.tsx +111 -0
  150. package/templates/ui/shadcn/components/badge.tsx +44 -0
  151. package/templates/ui/shadcn/components/button.tsx +66 -0
  152. package/templates/ui/shadcn/components/card.tsx +87 -0
  153. package/templates/ui/shadcn/components/dropdown-menu.tsx +268 -0
  154. package/templates/ui/shadcn/components/input.tsx +18 -0
  155. package/templates/ui/shadcn/components/label.tsx +20 -0
  156. package/templates/ui/shadcn/components/native-select.tsx +54 -0
  157. package/templates/ui/shadcn/components/skeleton.tsx +13 -0
  158. package/templates/ui/shadcn/components/table.tsx +115 -0
  159. package/templates/ui/shadcn/utils.ts +1 -0
  160. package/templates/ui/tailwind/components/alert-dialog.tsx +177 -0
  161. package/templates/ui/tailwind/components/avatar.tsx +36 -0
  162. package/templates/ui/tailwind/components/badge.tsx +29 -0
  163. package/templates/ui/tailwind/components/button.tsx +65 -0
  164. package/templates/ui/tailwind/components/card.tsx +70 -0
  165. package/templates/ui/tailwind/components/dropdown-menu.tsx +236 -0
  166. package/templates/ui/tailwind/components/input.tsx +17 -0
  167. package/templates/ui/tailwind/components/label.tsx +16 -0
  168. package/templates/ui/tailwind/components/native-select.tsx +32 -0
  169. package/templates/ui/tailwind/components/skeleton.tsx +13 -0
  170. package/templates/ui/tailwind/components/slot.tsx +34 -0
  171. package/templates/ui/tailwind/components/table.tsx +56 -0
  172. package/templates/ui/tailwind/utils.ts +1 -0
  173. package/templates/vite/Dockerfile +29 -0
  174. package/templates/vite/README.md +142 -0
  175. package/templates/vite/_dockerignore +14 -0
  176. package/templates/vite/_env.example +8 -0
  177. package/templates/vite/_gitignore +37 -0
  178. package/templates/vite/e2e/app.spec.ts +41 -0
  179. package/templates/vite/index.html +32 -0
  180. package/templates/vite/nginx.conf +26 -0
  181. package/templates/vite/package.json +61 -0
  182. package/templates/vite/playwright.config.ts +27 -0
  183. package/templates/vite/public/favicon.svg +1 -0
  184. package/templates/vite/src/App.test.tsx +28 -0
  185. package/templates/vite/src/App.tsx +26 -0
  186. package/templates/vite/src/components/home.tsx +121 -0
  187. package/templates/vite/src/components/layout/root-layout.tsx +18 -0
  188. package/templates/vite/src/components/layout/site-footer.tsx +10 -0
  189. package/templates/vite/src/components/layout/site-header.tsx +49 -0
  190. package/templates/vite/src/components/theme-toggle.tsx +90 -0
  191. package/templates/vite/src/env.ts +36 -0
  192. package/templates/vite/src/lib/theme.ts +26 -0
  193. package/templates/vite/src/main.tsx +13 -0
  194. package/templates/vite/src/pages/about.tsx +52 -0
  195. package/templates/vite/src/pages/not-found.tsx +33 -0
  196. package/templates/vite/src/router.ts +24 -0
  197. package/templates/vite/src/styles/app.css +281 -0
  198. package/templates/vite/src/test/setup.ts +21 -0
  199. package/templates/vite/tsconfig.app.json +31 -0
  200. package/templates/vite/tsconfig.json +7 -0
  201. package/templates/vite/tsconfig.node.json +23 -0
  202. package/templates/vite/vite.config.ts +30 -0
@@ -0,0 +1,74 @@
1
+ import {
2
+ // @feature email
3
+ after,
4
+ // @end email
5
+ NextResponse,
6
+ } from "next/server";
7
+
8
+ import { DEFAULT_ROLE, FIRST_USER_ROLE } from "@/config/rbac";
9
+ import {
10
+ ApiError,
11
+ apiHandler,
12
+ // @feature rate-limit
13
+ enforceRateLimit,
14
+ // @end rate-limit
15
+ parseBody,
16
+ } from "@/lib/api";
17
+ import { hashPassword, setSessionCookie } from "@/lib/auth";
18
+ import { connectDB } from "@/lib/db";
19
+ // @feature rate-limit
20
+ import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
21
+ // @end rate-limit
22
+ // @feature email
23
+ import { sendVerificationEmail } from "@/lib/tokens";
24
+ // @end email
25
+ import {
26
+ claimFirstAdmin,
27
+ isDuplicateKeyError,
28
+ releaseFirstAdmin,
29
+ toPublicUser,
30
+ } from "@/lib/users";
31
+ import { registerSchema } from "@/lib/validations/auth";
32
+ import { User } from "@/models/user";
33
+
34
+ const EMAIL_TAKEN = "An account with this email already exists";
35
+
36
+ export const POST = apiHandler(async (req) => {
37
+ // @feature rate-limit
38
+ enforceRateLimit(`register:${getClientIp(req)}`, RATE_LIMITS.register);
39
+ // @end rate-limit
40
+ const { name, email, password } = await parseBody(req, registerSchema);
41
+
42
+ await connectDB();
43
+ if (await User.exists({ email })) throw ApiError.conflict(EMAIL_TAKEN);
44
+
45
+ const passwordHash = await hashPassword(password);
46
+ // The very first account becomes admin; everyone after that is a regular user.
47
+ const isFirstUser = await claimFirstAdmin();
48
+
49
+ let created;
50
+ try {
51
+ created = await User.create({
52
+ name,
53
+ email,
54
+ password: passwordHash,
55
+ role: isFirstUser ? FIRST_USER_ROLE : DEFAULT_ROLE,
56
+ });
57
+ } catch (error) {
58
+ if (isFirstUser) await releaseFirstAdmin();
59
+ if (isDuplicateKeyError(error)) throw ApiError.conflict(EMAIL_TAKEN);
60
+ throw error;
61
+ }
62
+
63
+ const user = toPublicUser(created);
64
+ await setSessionCookie({ ...user, tokenVersion: created.tokenVersion ?? 0 });
65
+ // @feature email
66
+ // Send after the response so sign-up stays fast (and a mail outage can't break it).
67
+ after(() =>
68
+ sendVerificationEmail(user).catch((error) =>
69
+ console.error("[register] Failed to send verification email:", error),
70
+ ),
71
+ );
72
+ // @end email
73
+ return NextResponse.json({ user }, { status: 201 });
74
+ });
@@ -0,0 +1,25 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import {
4
+ ApiError,
5
+ // @feature rate-limit
6
+ enforceRateLimit,
7
+ // @end rate-limit
8
+ withAuth,
9
+ } from "@/lib/api";
10
+ // @feature rate-limit
11
+ import { RATE_LIMITS } from "@/lib/rate-limit";
12
+ // @end rate-limit
13
+ import { sendVerificationEmail } from "@/lib/tokens";
14
+
15
+ /** POST /api/auth/resend-verification (signed in) */
16
+ export const POST = withAuth(async (_req, _ctx, user) => {
17
+ // @feature rate-limit
18
+ enforceRateLimit(`resend-verification:${user.id}`, RATE_LIMITS.sensitive);
19
+ // @end rate-limit
20
+ if (user.emailVerified) {
21
+ throw ApiError.badRequest("Your email is already verified", "ALREADY_VERIFIED");
22
+ }
23
+ await sendVerificationEmail(user);
24
+ return NextResponse.json({ ok: true });
25
+ });
@@ -0,0 +1,43 @@
1
+ import { NextResponse } from "next/server";
2
+
3
+ import {
4
+ ApiError,
5
+ apiHandler,
6
+ // @feature rate-limit
7
+ enforceRateLimit,
8
+ // @end rate-limit
9
+ parseBody,
10
+ } from "@/lib/api";
11
+ import { hashPassword } from "@/lib/auth";
12
+ import { connectDB } from "@/lib/db";
13
+ // @feature rate-limit
14
+ import { getClientIp, RATE_LIMITS } from "@/lib/rate-limit";
15
+ // @end rate-limit
16
+ import { consumeToken } from "@/lib/tokens";
17
+ import { resetPasswordSchema } from "@/lib/validations/auth";
18
+ import { User } from "@/models/user";
19
+
20
+ /** POST /api/auth/reset-password { token, password } */
21
+ export const POST = apiHandler(async (req) => {
22
+ // @feature rate-limit
23
+ enforceRateLimit(`reset:${getClientIp(req)}`, RATE_LIMITS.passwordReset);
24
+ // @end rate-limit
25
+ const { token, password } = await parseBody(req, resetPasswordSchema);
26
+
27
+ const userId = await consumeToken(token, "password-reset");
28
+ if (!userId) {
29
+ throw ApiError.badRequest("This reset link is invalid or has expired", "INVALID_TOKEN");
30
+ }
31
+
32
+ await connectDB();
33
+ const updated = await User.findByIdAndUpdate(userId, {
34
+ password: await hashPassword(password),
35
+ // Sign out every existing session: whoever had the old password is out.
36
+ $inc: { tokenVersion: 1 },
37
+ });
38
+ if (!updated) throw ApiError.badRequest("This reset link is invalid or has expired", "INVALID_TOKEN");
39
+ // Clicking the emailed link proves the user owns the address.
40
+ await User.updateOne({ _id: userId, emailVerifiedAt: null }, { emailVerifiedAt: new Date() });
41
+
42
+ return NextResponse.json({ ok: true });
43
+ });
@@ -0,0 +1,29 @@
1
+ import { NextResponse, type NextRequest } from "next/server";
2
+
3
+ import { connectDB } from "@/lib/db";
4
+ import { consumeToken } from "@/lib/tokens";
5
+ import { User } from "@/models/user";
6
+
7
+ /**
8
+ * GET /api/auth/verify-email?token=... (the link in the verification email)
9
+ * Marks the email as verified, then redirects to /verify-email?status=...
10
+ */
11
+ export async function GET(request: NextRequest) {
12
+ const token = request.nextUrl.searchParams.get("token") ?? "";
13
+ const result = new URL("/verify-email", request.url);
14
+
15
+ try {
16
+ const userId = await consumeToken(token, "email-verification");
17
+ if (userId) {
18
+ await connectDB();
19
+ await User.updateOne({ _id: userId, emailVerifiedAt: null }, { emailVerifiedAt: new Date() });
20
+ result.searchParams.set("status", "success");
21
+ } else {
22
+ result.searchParams.set("status", "invalid");
23
+ }
24
+ } catch (error) {
25
+ console.error("[verify-email] Verification failed:", error);
26
+ result.searchParams.set("status", "error");
27
+ }
28
+ return NextResponse.redirect(result);
29
+ }
@@ -0,0 +1,27 @@
1
+ import { connection, NextResponse } from "next/server";
2
+
3
+ import { connectDB } from "@/lib/db";
4
+
5
+ /** GET /api/health: liveness + database check (used by the Docker HEALTHCHECK). */
6
+ export async function GET() {
7
+ await connection(); // always run at request time, never prerender
8
+
9
+ const started = Date.now();
10
+ const base = { uptime: Math.round(process.uptime()), timestamp: new Date().toISOString() };
11
+ const headers = { "Cache-Control": "no-store" };
12
+
13
+ try {
14
+ const mongoose = await connectDB();
15
+ await mongoose.connection.db?.admin().ping();
16
+ return NextResponse.json(
17
+ { status: "ok", database: "up", latencyMs: Date.now() - started, ...base },
18
+ { headers },
19
+ );
20
+ } catch (error) {
21
+ console.error("[health] Database check failed:", error);
22
+ return NextResponse.json(
23
+ { status: "error", database: "down", ...base },
24
+ { status: 503, headers },
25
+ );
26
+ }
27
+ }
@@ -0,0 +1,47 @@
1
+ import { ShieldAlert } from "lucide-react";
2
+ import type { Metadata } from "next";
3
+ import Link from "next/link";
4
+ import { Suspense } from "react";
5
+
6
+ import { SessionRefresher } from "@/components/auth/session-refresher";
7
+ import { Logo } from "@/components/logo";
8
+ import { Button } from "@/components/ui/button";
9
+
10
+ export const metadata: Metadata = { title: "Access denied" };
11
+
12
+ export default function ForbiddenPage() {
13
+ return (
14
+ <div className="status-page">
15
+ <header className="site-header">
16
+ <Logo />
17
+ </header>
18
+ <main className="status-page-main">
19
+ <div className="status-page-body">
20
+ <div className="status-icon status-icon--danger">
21
+ <ShieldAlert size={28} />
22
+ </div>
23
+ <div className="stack-sm">
24
+ <p className="status-code">403</p>
25
+ <h1 className="status-title">You don&apos;t have access to this page</h1>
26
+ <p className="muted text-sm">
27
+ Your role doesn&apos;t include the permission this page requires. If you think this is
28
+ a mistake, ask an admin to update your role.
29
+ </p>
30
+ </div>
31
+ {/* Reads ?from= with useSearchParams, so it needs a Suspense boundary. */}
32
+ <Suspense fallback={null}>
33
+ <SessionRefresher />
34
+ </Suspense>
35
+ <div className="button-row">
36
+ <Button asChild>
37
+ <Link href="/dashboard">Go to dashboard</Link>
38
+ </Button>
39
+ <Button asChild variant="outline">
40
+ <Link href="/">Home</Link>
41
+ </Button>
42
+ </div>
43
+ </div>
44
+ </main>
45
+ </div>
46
+ );
47
+ }
@@ -0,0 +1,55 @@
1
+ import type { Metadata } from "next";
2
+ import { Geist, Geist_Mono } from "next/font/google";
3
+ import type { CSSProperties } from "react";
4
+ import { Toaster } from "sonner";
5
+
6
+ import { siteConfig } from "@/config/site";
7
+ import { appUrl } from "@/lib/env";
8
+ import { themeScript } from "@/lib/theme";
9
+
10
+ import "./globals.css";
11
+ import "@/styles/app.css";
12
+
13
+ const geistSans = Geist({
14
+ variable: "--font-geist-sans",
15
+ subsets: ["latin"],
16
+ });
17
+
18
+ const geistMono = Geist_Mono({
19
+ variable: "--font-geist-mono",
20
+ subsets: ["latin"],
21
+ });
22
+
23
+ export const metadata: Metadata = {
24
+ metadataBase: new URL(appUrl()),
25
+ title: { default: siteConfig.name, template: `%s · ${siteConfig.name}` },
26
+ description: siteConfig.description,
27
+ // @feature seo
28
+ openGraph: { type: "website", siteName: siteConfig.name },
29
+ twitter: { card: "summary_large_image" },
30
+ // @end seo
31
+ };
32
+
33
+ export default function RootLayout({ children }: LayoutProps<"/">) {
34
+ return (
35
+ <html lang="en" className={`${geistSans.variable} ${geistMono.variable}`} suppressHydrationWarning>
36
+ <head>
37
+ <script dangerouslySetInnerHTML={{ __html: themeScript }} />
38
+ </head>
39
+ <body>
40
+ {children}
41
+ <Toaster
42
+ position="top-right"
43
+ closeButton
44
+ style={
45
+ {
46
+ "--normal-bg": "var(--popover)",
47
+ "--normal-text": "var(--popover-foreground)",
48
+ "--normal-border": "var(--border)",
49
+ } as CSSProperties
50
+ }
51
+ />
52
+ </body>
53
+ </html>
54
+ );
55
+ }
@@ -0,0 +1,20 @@
1
+ import Link from "next/link";
2
+
3
+ import { Button } from "@/components/ui/button";
4
+
5
+ export default function NotFound() {
6
+ return (
7
+ <main className="status-page-main">
8
+ <div className="status-page-body">
9
+ <p className="status-code">404</p>
10
+ <h1 className="status-title">Page not found</h1>
11
+ <p className="muted text-sm">
12
+ The page you&apos;re looking for doesn&apos;t exist or has been moved.
13
+ </p>
14
+ <Button asChild>
15
+ <Link href="/">Back home</Link>
16
+ </Button>
17
+ </div>
18
+ </main>
19
+ );
20
+ }
@@ -0,0 +1,49 @@
1
+ import { ImageResponse } from "next/og";
2
+
3
+ import { siteConfig } from "@/config/site";
4
+
5
+ export const alt = siteConfig.name;
6
+ export const size = { width: 1200, height: 630 };
7
+ export const contentType = "image/png";
8
+
9
+ /** The image shown when a link to the site is shared (generated at build time). */
10
+ export default function OpengraphImage() {
11
+ return new ImageResponse(
12
+ <div
13
+ style={{
14
+ width: "100%",
15
+ height: "100%",
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ justifyContent: "center",
19
+ padding: 80,
20
+ background: "linear-gradient(135deg, #0a0a0a 0%, #262626 100%)",
21
+ color: "#fafafa",
22
+ fontFamily: "sans-serif",
23
+ }}
24
+ >
25
+ <div
26
+ style={{
27
+ width: 72,
28
+ height: 72,
29
+ borderRadius: 18,
30
+ background: "#fafafa",
31
+ color: "#0a0a0a",
32
+ display: "flex",
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ fontSize: 40,
36
+ fontWeight: 700,
37
+ marginBottom: 40,
38
+ }}
39
+ >
40
+ {siteConfig.name.charAt(0)}
41
+ </div>
42
+ <div style={{ fontSize: 72, fontWeight: 700, lineHeight: 1.1 }}>{siteConfig.name}</div>
43
+ <div style={{ fontSize: 32, color: "#a3a3a3", marginTop: 24, maxWidth: 900 }}>
44
+ {siteConfig.description}
45
+ </div>
46
+ </div>,
47
+ size,
48
+ );
49
+ }
@@ -0,0 +1,165 @@
1
+ import {
2
+ ArrowRight,
3
+ Container,
4
+ Database,
5
+ KeyRound,
6
+ Layers,
7
+ ShieldCheck,
8
+ Sparkles,
9
+ } from "lucide-react";
10
+ import Link from "next/link";
11
+
12
+ import { Logo } from "@/components/logo";
13
+ import { FadeIn } from "@/components/motion/fade-in";
14
+ import { ThemeToggle } from "@/components/theme-toggle";
15
+ import { Badge } from "@/components/ui/badge";
16
+ import { Button } from "@/components/ui/button";
17
+ import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
18
+ import { siteConfig } from "@/config/site";
19
+
20
+ const FEATURES = [
21
+ {
22
+ icon: ShieldCheck,
23
+ title: "Role-based access control",
24
+ description:
25
+ "User, manager and admin roles with permissions defined in one file and enforced in three layers.",
26
+ },
27
+ {
28
+ icon: KeyRound,
29
+ title: "JWT authentication",
30
+ description:
31
+ "bcrypt-hashed passwords and HS256 tokens in httpOnly cookies. No auth vendor required.",
32
+ },
33
+ {
34
+ icon: Database,
35
+ title: "MongoDB + Mongoose",
36
+ description: "A cached connection that survives hot reloads, plus typed models.",
37
+ },
38
+ {
39
+ icon: Layers,
40
+ title: "UI kit with dark mode",
41
+ description: "Accessible components, CSS-variable theming (light, dark, system) and motion.",
42
+ },
43
+ {
44
+ icon: Sparkles,
45
+ title: "Validated end to end",
46
+ description: "zod schemas shared by forms and API routes.",
47
+ },
48
+ {
49
+ icon: Container,
50
+ title: "Ready to ship",
51
+ description: "Security headers, a health check and production-ready configuration.",
52
+ },
53
+ ];
54
+
55
+ const LAYERS = [
56
+ {
57
+ step: "1",
58
+ title: "Proxy",
59
+ file: "src/proxy.ts",
60
+ text: "Fast redirects based on the signed JWT.",
61
+ },
62
+ {
63
+ step: "2",
64
+ title: "Data Access Layer",
65
+ file: "src/lib/dal.ts",
66
+ text: "Re-reads the user from MongoDB on every request.",
67
+ },
68
+ {
69
+ step: "3",
70
+ title: "API guard",
71
+ file: "src/lib/api.ts",
72
+ text: "withAuth() returns 401/403 JSON for route handlers.",
73
+ },
74
+ ];
75
+
76
+ export default function HomePage() {
77
+ return (
78
+ <div className="landing">
79
+ <header className="site-header">
80
+ <Logo />
81
+ <div className="site-header-actions">
82
+ <ThemeToggle />
83
+ <Button asChild variant="ghost" size="sm">
84
+ <Link href="/login">Sign in</Link>
85
+ </Button>
86
+ <Button asChild size="sm">
87
+ <Link href="/register">Get started</Link>
88
+ </Button>
89
+ </div>
90
+ </header>
91
+
92
+ <main>
93
+ <section className="hero">
94
+ <FadeIn>
95
+ <Badge variant="outline">
96
+ <Sparkles /> Next.js 16 · React 19
97
+ </Badge>
98
+ </FadeIn>
99
+ <FadeIn delay={0.05}>
100
+ <h1 className="hero-title">Ship your full-stack app with auth and roles built in</h1>
101
+ </FadeIn>
102
+ <FadeIn delay={0.1}>
103
+ <p className="hero-lead">{siteConfig.description}</p>
104
+ </FadeIn>
105
+ <FadeIn delay={0.15} className="button-row button-row--center">
106
+ <Button asChild size="lg">
107
+ <Link href="/register">
108
+ Create an account <ArrowRight />
109
+ </Link>
110
+ </Button>
111
+ <Button asChild size="lg" variant="outline">
112
+ <Link href="/dashboard">Open dashboard</Link>
113
+ </Button>
114
+ </FadeIn>
115
+ <p className="muted text-xs">The first account you register becomes the admin.</p>
116
+ </section>
117
+
118
+ <section className="section">
119
+ <div className="cards-grid cards-grid--3">
120
+ {FEATURES.map(({ icon: Icon, title, description }, i) => (
121
+ <FadeIn key={title} delay={0.05 * i}>
122
+ <Card className="full-height">
123
+ <CardHeader>
124
+ <div className="feature-icon">
125
+ <Icon size={16} />
126
+ </div>
127
+ <CardTitle>{title}</CardTitle>
128
+ <CardDescription>{description}</CardDescription>
129
+ </CardHeader>
130
+ </Card>
131
+ </FadeIn>
132
+ ))}
133
+ </div>
134
+ </section>
135
+
136
+ <section className="section-band">
137
+ <div className="section">
138
+ <div className="section-intro">
139
+ <h2 className="section-title">Defense in depth, by default</h2>
140
+ <p className="muted">
141
+ Every request is checked at three layers, all driven by{" "}
142
+ <code className="code">src/config/rbac.ts</code>.
143
+ </p>
144
+ </div>
145
+ <ol className="cards-grid cards-grid--3">
146
+ {LAYERS.map((layer) => (
147
+ <li key={layer.step} className="layer-card">
148
+ <span className="muted mono text-xs">Layer {layer.step}</span>
149
+ <h3 className="layer-title">{layer.title}</h3>
150
+ <p className="muted text-sm">{layer.text}</p>
151
+ <code className="code">{layer.file}</code>
152
+ </li>
153
+ ))}
154
+ </ol>
155
+ </div>
156
+ </section>
157
+ </main>
158
+
159
+ <footer className="site-footer">
160
+ <span>{siteConfig.name}</span>
161
+ <span>Built with create-mohit-next</span>
162
+ </footer>
163
+ </div>
164
+ );
165
+ }
@@ -0,0 +1,15 @@
1
+ import type { MetadataRoute } from "next";
2
+
3
+ import { appUrl } from "@/lib/env";
4
+
5
+ /** /robots.txt */
6
+ export default function robots(): MetadataRoute.Robots {
7
+ return {
8
+ rules: {
9
+ userAgent: "*",
10
+ allow: "/",
11
+ disallow: ["/api/", "/dashboard", "/reports", "/admin", "/settings"],
12
+ },
13
+ sitemap: `${appUrl()}/sitemap.xml`,
14
+ };
15
+ }
@@ -0,0 +1,13 @@
1
+ import type { MetadataRoute } from "next";
2
+
3
+ import { appUrl } from "@/lib/env";
4
+
5
+ /** /sitemap.xml: public pages only (authenticated pages are excluded on purpose). */
6
+ export default function sitemap(): MetadataRoute.Sitemap {
7
+ const base = appUrl();
8
+ return [
9
+ { url: `${base}/`, changeFrequency: "weekly", priority: 1 },
10
+ { url: `${base}/login`, changeFrequency: "yearly", priority: 0.5 },
11
+ { url: `${base}/register`, changeFrequency: "yearly", priority: 0.5 },
12
+ ];
13
+ }
@@ -0,0 +1,23 @@
1
+ import type { Metadata } from "next";
2
+ import { Suspense } from "react";
3
+
4
+ import { VerifyEmailStatus } from "@/components/auth/verify-email-status";
5
+ import { Logo } from "@/components/logo";
6
+
7
+ export const metadata: Metadata = { title: "Verify email" };
8
+
9
+ export default function VerifyEmailPage() {
10
+ return (
11
+ <div className="status-page">
12
+ <header className="site-header">
13
+ <Logo />
14
+ </header>
15
+ <main className="status-page-main">
16
+ {/* Reads ?status= with useSearchParams, so it needs a Suspense boundary. */}
17
+ <Suspense fallback={null}>
18
+ <VerifyEmailStatus />
19
+ </Suspense>
20
+ </main>
21
+ </div>
22
+ );
23
+ }