create-stackrjs 1.4.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 (113) hide show
  1. package/README.md +154 -0
  2. package/dist/index.js +1135 -0
  3. package/package.json +62 -0
  4. package/template/architectures/microservices/_gitignore +26 -0
  5. package/template/architectures/microservices/apps/web/Dockerfile +11 -0
  6. package/template/architectures/microservices/apps/web/next-env.d.ts +5 -0
  7. package/template/architectures/microservices/apps/web/next.config.mjs +4 -0
  8. package/template/architectures/microservices/apps/web/package.json +25 -0
  9. package/template/architectures/microservices/apps/web/src/app/account/page.tsx +56 -0
  10. package/template/architectures/microservices/apps/web/src/app/globals.css +3 -0
  11. package/template/architectures/microservices/apps/web/src/app/layout.tsx +16 -0
  12. package/template/architectures/microservices/apps/web/src/app/login/page.tsx +70 -0
  13. package/template/architectures/microservices/apps/web/src/app/page.tsx +33 -0
  14. package/template/architectures/microservices/apps/web/src/app/register/page.tsx +71 -0
  15. package/template/architectures/microservices/apps/web/src/lib/api.ts +15 -0
  16. package/template/architectures/microservices/apps/web/tsconfig.json +23 -0
  17. package/template/architectures/microservices/docker-compose.yml +45 -0
  18. package/template/architectures/microservices/gateway/nginx.conf +20 -0
  19. package/template/architectures/microservices/package.json +21 -0
  20. package/template/architectures/microservices/services/api/Dockerfile +11 -0
  21. package/template/architectures/microservices/services/api/package.json +34 -0
  22. package/template/architectures/microservices/services/api/prisma/schema.prisma +17 -0
  23. package/template/architectures/microservices/services/api/prisma.config.ts +17 -0
  24. package/template/architectures/microservices/services/api/src/auth.ts +22 -0
  25. package/template/architectures/microservices/services/api/src/db.ts +12 -0
  26. package/template/architectures/microservices/services/api/src/index.ts +22 -0
  27. package/template/architectures/microservices/services/api/src/routes/auth.ts +73 -0
  28. package/template/architectures/microservices/services/api/tsconfig.json +16 -0
  29. package/template/base/_eslintrc.json +3 -0
  30. package/template/base/_gitignore +24 -0
  31. package/template/base/_prettierrc.json +6 -0
  32. package/template/base/next-env.d.ts +5 -0
  33. package/template/base/next.config.mjs +4 -0
  34. package/template/base/package.json +27 -0
  35. package/template/base/src/app/globals.css +14 -0
  36. package/template/base/src/app/layout.tsx +16 -0
  37. package/template/base/src/app/page.tsx +10 -0
  38. package/template/base/tsconfig.json +23 -0
  39. package/template/extras/account-better-auth/src/server/account.ts +52 -0
  40. package/template/extras/account-clerk/src/server/account.ts +64 -0
  41. package/template/extras/account-nextauth/src/server/account.ts +59 -0
  42. package/template/extras/account-supabase/src/lib/supabase/admin.ts +14 -0
  43. package/template/extras/account-supabase/src/server/account.ts +65 -0
  44. package/template/extras/admin/src/app/admin/page.tsx +55 -0
  45. package/template/extras/auth-pages/src/app/account/page.tsx +37 -0
  46. package/template/extras/auth-pages/src/app/forgot-password/page.tsx +33 -0
  47. package/template/extras/auth-pages/src/app/login/page.tsx +32 -0
  48. package/template/extras/auth-pages/src/app/page.tsx +46 -0
  49. package/template/extras/auth-pages/src/app/register/page.tsx +36 -0
  50. package/template/extras/auth-pages/src/app/reset-password/page.tsx +49 -0
  51. package/template/extras/auth-pages/src/components/auth/ui.tsx +57 -0
  52. package/template/extras/auth-pages-drizzle/src/server/actions.ts +122 -0
  53. package/template/extras/auth-pages-mongoose/src/server/actions.ts +121 -0
  54. package/template/extras/auth-pages-prisma/src/server/actions.ts +117 -0
  55. package/template/extras/better-auth/prisma/schema.prisma +70 -0
  56. package/template/extras/better-auth/src/app/account/page.tsx +42 -0
  57. package/template/extras/better-auth/src/app/api/auth/[...all]/route.ts +5 -0
  58. package/template/extras/better-auth/src/app/login/page.tsx +42 -0
  59. package/template/extras/better-auth/src/app/register/page.tsx +44 -0
  60. package/template/extras/better-auth/src/components/auth/ui.tsx +58 -0
  61. package/template/extras/better-auth/src/lib/auth-client.ts +7 -0
  62. package/template/extras/better-auth/src/server/auth.ts +13 -0
  63. package/template/extras/clerk/middleware.ts +14 -0
  64. package/template/extras/clerk/src/app/account/page.tsx +30 -0
  65. package/template/extras/clerk/src/app/layout.tsx +19 -0
  66. package/template/extras/clerk/src/app/page.tsx +40 -0
  67. package/template/extras/clerk/src/app/sign-in/[[...sign-in]]/page.tsx +9 -0
  68. package/template/extras/clerk/src/app/sign-up/[[...sign-up]]/page.tsx +9 -0
  69. package/template/extras/dashboard/src/app/dashboard/page.tsx +48 -0
  70. package/template/extras/databases/mongodb/docker-compose.yml +13 -0
  71. package/template/extras/databases/mysql/docker-compose.yml +14 -0
  72. package/template/extras/databases/postgres/docker-compose.yml +15 -0
  73. package/template/extras/drizzle/mysql/drizzle.config.ts +9 -0
  74. package/template/extras/drizzle/mysql/src/server/db.ts +11 -0
  75. package/template/extras/drizzle/mysql/src/server/schema.ts +17 -0
  76. package/template/extras/drizzle/postgres/drizzle.config.ts +9 -0
  77. package/template/extras/drizzle/postgres/src/server/db.ts +11 -0
  78. package/template/extras/drizzle/postgres/src/server/schema.ts +20 -0
  79. package/template/extras/landing/src/app/page.tsx +53 -0
  80. package/template/extras/mongoose/src/server/db.ts +12 -0
  81. package/template/extras/mongoose/src/server/models.ts +25 -0
  82. package/template/extras/nextauth/middleware.ts +11 -0
  83. package/template/extras/nextauth/src/app/api/auth/[...nextauth]/route.ts +3 -0
  84. package/template/extras/nextauth/src/server/auth.config.ts +39 -0
  85. package/template/extras/nextauth/src/server/roles.ts +5 -0
  86. package/template/extras/nextauth/src/types/next-auth.d.ts +22 -0
  87. package/template/extras/nextauth-drizzle/src/server/auth.ts +44 -0
  88. package/template/extras/nextauth-mongoose/src/server/auth.ts +42 -0
  89. package/template/extras/nextauth-prisma/src/server/auth.ts +43 -0
  90. package/template/extras/prisma/base/prisma/schema.prisma +67 -0
  91. package/template/extras/prisma/base/prisma.config.ts +10 -0
  92. package/template/extras/prisma/mysql/src/server/db.ts +25 -0
  93. package/template/extras/prisma/postgres/src/server/db.ts +18 -0
  94. package/template/extras/shadcn/components.json +20 -0
  95. package/template/extras/shadcn/postcss.config.mjs +7 -0
  96. package/template/extras/shadcn/src/app/globals.css +59 -0
  97. package/template/extras/shadcn/src/components/ui/button.tsx +42 -0
  98. package/template/extras/shadcn/src/components/ui/card.tsx +54 -0
  99. package/template/extras/shadcn/src/components/ui/input.tsx +19 -0
  100. package/template/extras/shadcn/src/lib/utils.ts +7 -0
  101. package/template/extras/shadcn/tailwind.config.ts +71 -0
  102. package/template/extras/supabase/middleware.ts +13 -0
  103. package/template/extras/supabase/src/app/account/page.tsx +32 -0
  104. package/template/extras/supabase/src/app/login/page.tsx +47 -0
  105. package/template/extras/supabase/src/app/register/page.tsx +52 -0
  106. package/template/extras/supabase/src/components/auth/sign-out-button.tsx +25 -0
  107. package/template/extras/supabase/src/components/auth/ui.tsx +58 -0
  108. package/template/extras/supabase/src/lib/supabase/client.ts +9 -0
  109. package/template/extras/supabase/src/lib/supabase/middleware.ts +34 -0
  110. package/template/extras/supabase/src/lib/supabase/server.ts +29 -0
  111. package/template/extras/tailwind/postcss.config.mjs +7 -0
  112. package/template/extras/tailwind/src/app/globals.css +3 -0
  113. package/template/extras/tailwind/tailwind.config.ts +9 -0
@@ -0,0 +1,52 @@
1
+ "use client";
2
+
3
+ import { useState, type FormEvent } from "react";
4
+ import { useRouter } from "next/navigation";
5
+ import { createClient } from "@/lib/supabase/client";
6
+ import { Alert, AuthShell, Field, FooterLinks, SubmitButton, TextLink } from "@/components/auth/ui";
7
+
8
+ export default function RegisterPage() {
9
+ const router = useRouter();
10
+ const [error, setError] = useState<string | null>(null);
11
+ const [message, setMessage] = useState<string | null>(null);
12
+ const [pending, setPending] = useState(false);
13
+
14
+ async function onSubmit(event: FormEvent<HTMLFormElement>) {
15
+ event.preventDefault();
16
+ setPending(true);
17
+ setError(null);
18
+ const data = new FormData(event.currentTarget);
19
+ const supabase = createClient();
20
+ const { data: result, error } = await supabase.auth.signUp({
21
+ email: String(data.get("email")),
22
+ password: String(data.get("password")),
23
+ });
24
+ setPending(false);
25
+ if (error) {
26
+ setError(error.message);
27
+ } else if (result.session) {
28
+ router.push("/account");
29
+ router.refresh();
30
+ } else {
31
+ // Email confirmation is enabled on the project — prompt the user.
32
+ setMessage("Check your inbox to confirm your email, then sign in.");
33
+ }
34
+ }
35
+
36
+ return (
37
+ <AuthShell title="Create account">
38
+ {error && <Alert kind="error">{error}</Alert>}
39
+ {message && <Alert kind="success">{message}</Alert>}
40
+ <form onSubmit={onSubmit}>
41
+ <Field label="Email" name="email" type="email" required autoComplete="email" />
42
+ <Field label="Password" name="password" type="password" required minLength={8} autoComplete="new-password" />
43
+ <SubmitButton disabled={pending}>{pending ? "Creating…" : "Create account"}</SubmitButton>
44
+ </form>
45
+ <FooterLinks>
46
+ <p>
47
+ Already have an account? <TextLink href="/login">Sign in</TextLink>
48
+ </p>
49
+ </FooterLinks>
50
+ </AuthShell>
51
+ );
52
+ }
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import { useRouter } from "next/navigation";
4
+ import { createClient } from "@/lib/supabase/client";
5
+
6
+ export function SignOutButton() {
7
+ const router = useRouter();
8
+
9
+ async function signOut() {
10
+ const supabase = createClient();
11
+ await supabase.auth.signOut();
12
+ router.push("/login");
13
+ router.refresh();
14
+ }
15
+
16
+ return (
17
+ <button
18
+ type="button"
19
+ onClick={signOut}
20
+ className="w-full rounded-md bg-gray-900 px-3 py-2 text-sm font-medium text-white transition hover:bg-gray-700"
21
+ >
22
+ Sign out
23
+ </button>
24
+ );
25
+ }
@@ -0,0 +1,58 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ import Link from "next/link";
3
+
4
+ /** Centered card shell shared by all auth pages. */
5
+ export function AuthShell({ title, children }: { title: string; children: ReactNode }) {
6
+ return (
7
+ <main className="flex min-h-screen items-center justify-center bg-gray-50 p-4">
8
+ <div className="w-full max-w-sm rounded-xl border border-gray-200 bg-white p-8 shadow-sm">
9
+ <h1 className="mb-6 text-2xl font-semibold tracking-tight">{title}</h1>
10
+ {children}
11
+ </div>
12
+ </main>
13
+ );
14
+ }
15
+
16
+ export function Field({ label, ...props }: { label: string } & ComponentProps<"input">) {
17
+ return (
18
+ <label className="mb-4 block">
19
+ <span className="mb-1 block text-sm font-medium text-gray-700">{label}</span>
20
+ <input
21
+ {...props}
22
+ className="w-full rounded-md border border-gray-300 px-3 py-2 text-sm outline-none focus:border-gray-900"
23
+ />
24
+ </label>
25
+ );
26
+ }
27
+
28
+ export function SubmitButton({ children, ...props }: ComponentProps<"button">) {
29
+ return (
30
+ <button
31
+ {...props}
32
+ type="submit"
33
+ className="w-full rounded-md bg-gray-900 px-3 py-2 text-sm font-medium text-white transition hover:bg-gray-700 disabled:opacity-60"
34
+ >
35
+ {children}
36
+ </button>
37
+ );
38
+ }
39
+
40
+ export function Alert({ kind, children }: { kind: "error" | "success"; children: ReactNode }) {
41
+ const styles =
42
+ kind === "error"
43
+ ? "bg-red-50 text-red-700 border-red-200"
44
+ : "bg-green-50 text-green-700 border-green-200";
45
+ return <p className={`mb-4 rounded-md border px-3 py-2 text-sm ${styles}`}>{children}</p>;
46
+ }
47
+
48
+ export function FooterLinks({ children }: { children: ReactNode }) {
49
+ return <div className="mt-6 space-y-1 text-center text-sm text-gray-500">{children}</div>;
50
+ }
51
+
52
+ export function TextLink({ href, children }: { href: string; children: ReactNode }) {
53
+ return (
54
+ <Link href={href} className="font-medium text-gray-900 underline-offset-2 hover:underline">
55
+ {children}
56
+ </Link>
57
+ );
58
+ }
@@ -0,0 +1,9 @@
1
+ import { createBrowserClient } from "@supabase/ssr";
2
+
3
+ /** Supabase client for use in Client Components. */
4
+ export function createClient() {
5
+ return createBrowserClient(
6
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
7
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
8
+ );
9
+ }
@@ -0,0 +1,34 @@
1
+ import { createServerClient, type CookieOptions } from "@supabase/ssr";
2
+ import { NextResponse, type NextRequest } from "next/server";
3
+
4
+ type CookieToSet = { name: string; value: string; options: CookieOptions };
5
+
6
+ /** Refresh the Supabase auth session on every request and propagate cookies. */
7
+ export async function updateSession(request: NextRequest) {
8
+ let supabaseResponse = NextResponse.next({ request });
9
+
10
+ const supabase = createServerClient(
11
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
12
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
13
+ {
14
+ cookies: {
15
+ getAll() {
16
+ return request.cookies.getAll();
17
+ },
18
+ setAll(cookiesToSet: CookieToSet[]) {
19
+ cookiesToSet.forEach(({ name, value }) => request.cookies.set(name, value));
20
+ supabaseResponse = NextResponse.next({ request });
21
+ cookiesToSet.forEach(({ name, value, options }) =>
22
+ supabaseResponse.cookies.set(name, value, options),
23
+ );
24
+ },
25
+ },
26
+ },
27
+ );
28
+
29
+ // Touch the user so Supabase rotates tokens; do not run logic between this and
30
+ // returning supabaseResponse.
31
+ await supabase.auth.getUser();
32
+
33
+ return supabaseResponse;
34
+ }
@@ -0,0 +1,29 @@
1
+ import { createServerClient, type CookieOptions } from "@supabase/ssr";
2
+ import { cookies } from "next/headers";
3
+
4
+ type CookieToSet = { name: string; value: string; options: CookieOptions };
5
+
6
+ /** Supabase client for use in Server Components, Route Handlers and Server Actions. */
7
+ export async function createClient() {
8
+ const cookieStore = await cookies();
9
+
10
+ return createServerClient(
11
+ process.env.NEXT_PUBLIC_SUPABASE_URL!,
12
+ process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
13
+ {
14
+ cookies: {
15
+ getAll() {
16
+ return cookieStore.getAll();
17
+ },
18
+ setAll(cookiesToSet: CookieToSet[]) {
19
+ // Can throw in Server Components; the middleware refreshes the session.
20
+ try {
21
+ cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
22
+ } catch {
23
+ // ignore — set from a Server Component
24
+ }
25
+ },
26
+ },
27
+ },
28
+ );
29
+ }
@@ -0,0 +1,7 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ export default {
3
+ plugins: {
4
+ tailwindcss: {},
5
+ autoprefixer: {},
6
+ },
7
+ };
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,9 @@
1
+ import type { Config } from "tailwindcss";
2
+
3
+ export default {
4
+ content: ["./src/**/*.{ts,tsx,js,jsx,mdx}"],
5
+ theme: {
6
+ extend: {},
7
+ },
8
+ plugins: [],
9
+ } satisfies Config;