Skip to content

Commit d37c29a

Browse files
committed
refactor(auth, middleware): remove unused login and signup functions, streamline logout functionality and redirect root path to home and clean up public routes
1 parent d82cca5 commit d37c29a

File tree

9 files changed

+21
-315
lines changed

9 files changed

+21
-315
lines changed

src/actions/auth.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,7 @@
11
"use server";
22

3-
import { revalidatePath } from "next/cache";
4-
import { redirect } from "next/navigation";
53
import { createClient } from "@/lib/supabase/server";
64

7-
export async function login(formData: FormData) {
8-
const supabase = await createClient();
9-
10-
const data = {
11-
email: formData.get("email") as string,
12-
password: formData.get("password") as string,
13-
};
14-
15-
const { error } = await supabase.auth.signInWithPassword(data);
16-
17-
if (error) {
18-
redirect("/error");
19-
}
20-
21-
revalidatePath("/", "layout");
22-
redirect("/");
23-
}
24-
25-
export async function signup(formData: FormData) {
26-
const supabase = await createClient();
27-
28-
const data = {
29-
email: formData.get("email") as string,
30-
password: formData.get("password") as string,
31-
};
32-
33-
const { error } = await supabase.auth.signUp(data);
34-
35-
if (error) {
36-
redirect("/error");
37-
}
38-
39-
revalidatePath("/", "layout");
40-
redirect("/");
41-
}
42-
435
export async function logout() {
446
const supabase = await createClient();
457
await supabase.auth.signOut();

src/app/(private)/dashboard/page.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/app/(public)/authors/page.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/app/page.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/components/layout/navigation.tsx

Lines changed: 0 additions & 131 deletions
This file was deleted.

src/config/constants.tsx

Lines changed: 5 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,19 @@
1-
import {
2-
ChartNoAxesColumn,
3-
Scissors,
4-
Link as Link2,
5-
Globe,
6-
Folder,
7-
Gem,
8-
HeartHandshake,
9-
MousePointer2,
10-
} from "lucide-react";
11-
121
// Project
132
export const PROJECT_NAME = "Code Atlas";
143

15-
export const PROJECT_DESCRIPTION = "Pending.";
4+
export const PROJECT_DESCRIPTION = "A curated list of resources for developers";
165

176
export const PROJECT_DOMAIN = new URL(
187
process.env.NEXT_PUBLIC_PROJECT_DOMAIN || "http://localhost:3000",
198
);
209

21-
// Interface
22-
export const NAV_ITEMS = [{ key: "home", href: "/", label: "Inicio" }];
10+
export const PROJECT_AUTHOR = "Tyrone Jose";
2311

24-
export const SIDEBAR_ITEMS = [
25-
{
26-
href: "/dashboard",
27-
label: "Dashboard",
28-
icon: <ChartNoAxesColumn size={20} className="flex-shrink-0" />,
29-
},
30-
{
31-
href: "/dashboard/cutter",
32-
label: "Cutter",
33-
icon: <Scissors size={20} className="flex-shrink-0" />,
34-
},
35-
{
36-
href: "/dashboard/links",
37-
label: "Links",
38-
icon: <Link2 size={20} className="flex-shrink-0" />,
39-
},
40-
{
41-
href: "/dashboard/clicks",
42-
label: "Clicks",
43-
icon: <MousePointer2 size={20} className="flex-shrink-0" />,
44-
},
45-
{
46-
href: "/dashboard/domains",
47-
label: "Domains",
48-
icon: <Globe size={20} className="flex-shrink-0" />,
49-
},
50-
{
51-
href: "/dashboard/groups",
52-
label: "Groups",
53-
icon: <Folder size={20} className="flex-shrink-0" />,
54-
},
55-
{
56-
href: "/dashboard/prices",
57-
label: "Prices",
58-
icon: <Gem size={20} className="flex-shrink-0" />,
59-
},
60-
{
61-
href: "/dashboard/support",
62-
label: "Support",
63-
icon: <HeartHandshake size={20} className="flex-shrink-0" />,
64-
},
65-
];
12+
export const PROJECT_AUTHOR_URL = "https://github.com/tyronejosee";
6613

67-
export const FOOTER_LINKS = [
68-
{ name: "Resources", href: "/resources" },
69-
{ name: "Authors", href: "/authors" },
70-
{ name: "Blog", href: "/blog" },
71-
];
14+
// Interface
7215

73-
export const SECTIONS = [
74-
{
75-
key: "4fbcd2fc-14cd-4048-83c5-c683ccd8c212",
76-
title: "Explore",
77-
items: [
78-
{ title: "Resources", path: "/resources" },
79-
{ title: "Authors", path: "/authors" },
80-
],
81-
},
82-
{
83-
key: "4fbcd2fc-14cd-4048-83c5-c683ccd8c216",
84-
title: "Languages",
85-
items: [
86-
{ title: "Python", path: "/languages/python" },
87-
{ title: "JavaScript", path: "/languages/javascript" },
88-
{ title: "TypeScript", path: "/languages/typescript" },
89-
{ title: "Ruby", path: "/languages/ruby" },
90-
],
91-
},
92-
{
93-
key: "b0f0c9a0-a4c0-4a5f-b3a8-e0a2f5a1c2b1",
94-
title: "Frameworks & Libraries",
95-
items: [
96-
{ title: "Django", path: "/frameworks-libraries/django" },
97-
{ title: "Flask", path: "/frameworks-libraries/flask" },
98-
{ title: "FastAPI", path: "/frameworks-libraries/fastapi" },
99-
{ title: "Express", path: "/frameworks-libraries/express" },
100-
],
101-
},
102-
];
16+
export const HOME_PATH = "/resources";
10317

10418
export const SORT_OPTIONS = [
10519
{ key: "latest", label: "Recent" },

src/lib/supabase/middleware.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { createServerClient } from "@supabase/ssr";
21
import { NextResponse, type NextRequest } from "next/server";
2+
import { createServerClient } from "@supabase/ssr";
3+
import { HOME_PATH } from "@/config/constants";
34

4-
const publicRoutes = ["/", "/auth/login", "/resources"];
5-
const publicRoutePrefixes = [
6-
"/auth/",
7-
"/resources/",
8-
"/languages/",
9-
"/frameworks-libraries/",
5+
const publicRoutes = [
6+
HOME_PATH,
7+
"/explore",
8+
"/trending",
9+
"/feedback",
10+
"/blog",
11+
"/faqs",
1012
];
13+
const publicRoutePrefixes = ["/auth/", "/resources/"];
1114

1215
export async function updateSession(request: NextRequest) {
1316
let supabaseResponse = NextResponse.next({

src/middleware.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { type NextRequest } from "next/server";
1+
import { type NextRequest, NextResponse } from "next/server";
22

33
import { updateSession } from "@/lib/supabase/middleware";
4+
import { HOME_PATH } from "@/config/constants";
45

56
export async function middleware(request: NextRequest) {
7+
if (request.nextUrl.pathname === "/") {
8+
return NextResponse.redirect(new URL(HOME_PATH, request.url));
9+
}
610
return await updateSession(request);
711
}
812

src/styles/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010
html {
11-
@apply text-neutral-950 dark:text-white selection:bg-neutral-950 selection:text-white;
11+
@apply text-neutral-950 dark:text-white selection:bg-neutral-950 selection:text-white dark:selection:bg-white dark:selection:text-neutral-950;
1212
}
1313

1414
body {

0 commit comments

Comments
 (0)