Skip to content

Commit

Permalink
Merge pull request #3 from esbnet/feature/clerk-auth
Browse files Browse the repository at this point in the history
Feature/clerk auth
  • Loading branch information
esbnet authored Mar 4, 2024
2 parents 5f70903 + a528224 commit 176f8c8
Show file tree
Hide file tree
Showing 19 changed files with 654 additions and 59 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
8 changes: 8 additions & 0 deletions __middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { i18n } from "@/i18n";
import createMiddleware from "next-intl/middleware";

export default createMiddleware(i18n);

export const config = {
matcher: ["/((?!api|_next|.*\\..*).*)"],
};
5 changes: 5 additions & 0 deletions app/(auth)/(routes)/sign-in/[[...sign-in]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUp } from "@clerk/nextjs";

export default function Page() {
return <SignUp />;
}
5 changes: 5 additions & 0 deletions app/(auth)/(routes)/sign-up/[[...sign-up]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SignUp } from "@clerk/nextjs";

export default function Page() {
return <SignUp />;
}
13 changes: 13 additions & 0 deletions app/(auth)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Locale } from "@/i18n";

export default function AuthLayout({
children,
params,
}: {
children: React.ReactNode;
params: { locale: Locale };
}) {
return (
<div className="flex items-center justify-center h-full">{children}</div>
);
}
11 changes: 11 additions & 0 deletions app/(dashboard)/(routes)/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Locale } from "@/i18n";
import { UserButton } from "@clerk/nextjs";

export default function Dashboard({ params }: { params: { locale: Locale } }) {
return (
<div>
<p>Dashboard Page</p>
<UserButton afterSignOutUrl="/" />
</div>
);
}
18 changes: 18 additions & 0 deletions app/(landing)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Button } from "@/components/ui/button";
import Link from "next/link";

export default function LandingPage() {
return (
<div>
Landing Page (desprotegido)
<div>
<Link href="/sign-in">
<Button>Login</Button>
</Link>
<Link href="/sign-up">
<Button>Register</Button>
</Link>
</div>
</div>
);
}
7 changes: 0 additions & 7 deletions app/[locale]/(dashboard)/(routes)/dashboard/page.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions app/[locale]/(landing)/page.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions app/[locale]/tmp.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions app/api/auth/[kindeAuth]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";

export const GET = handleAuth();
File renamed without changes.
File renamed without changes.
25 changes: 13 additions & 12 deletions app/[locale]/layout.tsx → app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { i18n } from "@/i18n";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

import { ClerkProvider } from "@clerk/nextjs";

const inter = Inter({ subsets: ["latin"] });

export async function generateStaticParams() {
const languages = i18n.locales.map((locale) => ({
locale,
}));
// export async function generateStaticParams() {
// const languages = i18n.locales.map((locale) => ({
// locale,
// }));

return languages;
}
// return languages;
// }

export const metadata: Metadata = {
title: "Genius",
Expand All @@ -20,14 +21,14 @@ export const metadata: Metadata = {

export default function RootLayout({
children,
params,
}: Readonly<{
children: React.ReactNode;
params: { locale: string };
}>) {
return (
<html lang={params.locale}>
<body className={inter.className}>{children}</body>
</html>
<ClerkProvider>
<html lang="pt-BR">
<body className={inter.className}>{children}</body>
</html>
</ClerkProvider>
);
}
1 change: 1 addition & 0 deletions i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const i18n = {
defaultLocale,
locales,
localeDetection: true,
publicRoutes: ["/"],
};

export type Locale = (typeof langs)[number];
Expand Down
9 changes: 5 additions & 4 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { i18n } from "@/i18n";
import createMiddleware from "next-intl/middleware";
import { authMiddleware } from "@clerk/nextjs";

export default createMiddleware(i18n);
export default authMiddleware({
publicRoutes: ["/", "/api/webhook"],
});

export const config = {
matcher: ["/((?!api|_next|.*\\..*).*)"],
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
7 changes: 4 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import createNextIntlPlugin from "next-intl/plugin";
// import createNextIntlPlugin from "next-intl/plugin";

const withNextIntl = createNextIntlPlugin();
// const withNextIntl = createNextIntlPlugin();

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default withNextIntl(nextConfig);
// export default withNextIntl(nextConfig);
export default nextConfig;
Loading

0 comments on commit 176f8c8

Please sign in to comment.