Skip to content

Commit 003b678

Browse files
authored
update deps last version (#24)
- new auth and prisma versions - address the type safety on new version adapter - address migration to eslint 9+ - some new eslint rules and necessary changes - several other updates
1 parent fdc4f93 commit 003b678

File tree

22 files changed

+1467
-1201
lines changed

22 files changed

+1467
-1201
lines changed

.eslintrc.json

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

app/(auth)/layout.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
export default function AuthLayout({ children }: { children: React.ReactNode }) {
1+
import type { ReactNode } from 'react';
2+
3+
export default function AuthLayout({ children }: { children: ReactNode }) {
24
return (
35
<>
4-
<div
5-
className='flex h-full items-center justify-center
6-
bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))]
7-
from-sky-400 to-blue-800'
8-
>
6+
<div className='flex h-full items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'>
97
{children}
108
</div>
119
</>

app/(protected)/client/client-component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export default function ClientComponent() {
1616
const userSession: Session['user'] | undefined = useCurrentUser();
1717
return (
1818
<div className=''>
19-
{/* This userInfo component is what we call a hybrid component, as children of a client component, is a client component */}
19+
{/* This userInfo component is what we call a hybrid component,
20+
as children of a client component, it is a client component */}
2021
<UserInfo label='💃Client component' user={userSession} />
2122
</div>
2223
);

app/(protected)/layout.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { Navbar } from '@/components/layout/Navbar';
22
import { NavigationMenu } from '@/components/layout/navbar/NavigationMenu';
33
import { UserAvatarMenu } from '@/components/layout/navbar/UserAvatarMenu';
44

5-
export default function ProtectedLayout(props: { children: React.ReactNode }) {
5+
import type { ReactNode } from 'react';
6+
7+
export default function ProtectedLayout(props: { children: ReactNode }) {
68
return (
7-
<div
8-
className='flex min-h-svh w-full flex-col items-center gap-y-10 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))]
9-
from-sky-400 to-blue-800 py-5'
10-
>
9+
<div className='flex min-h-svh w-full flex-col items-center gap-y-10 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800 py-5'>
1110
<Navbar>
1211
<NavigationMenu />
1312
<UserAvatarMenu />

app/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Inter } from 'next/font/google';
33
import { Toaster } from '@/components/ui/sonner';
44

55
import type { Metadata } from 'next';
6+
import type { ReactNode } from 'react';
67

78
import './globals.css';
89

@@ -16,7 +17,7 @@ export const metadata: Metadata = {
1617
export default async function RootLayout({
1718
children,
1819
}: Readonly<{
19-
children: React.ReactNode;
20+
children: ReactNode;
2021
}>) {
2122
return (
2223
<html lang='en'>

app/page.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ const font = Poppins({
1010
});
1111
export default function Home() {
1212
return (
13-
<main
14-
className='flex h-full flex-col items-center justify-center
15-
bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'
16-
>
13+
<main className='flex h-full flex-col items-center justify-center bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-sky-400 to-blue-800'>
1714
<div className='space-y-6 text-center'>
1815
<h1 className={cn('text-6xl font-semibold text-white drop-shadow-md', font.className)}>
1916
<span aria-label='icon' role='img'>

auth.config.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ const adapter = {
2424
* Used when sending magic links
2525
*
2626
* @note If it fails, the email will still be sent, a bug, or intended? Did not bother much.
27-
* @note Remove id and hashedIp from the return object to match PrismaAdapter original patterns
27+
* @note Remove id from the return object to match PrismaAdapter original patterns, we do not have id tho, currently.
2828
*/
29-
async createVerificationToken(
30-
data: VerificationToken
31-
): Promise<{ identifier: string; expires: Date; token: string }> {
29+
async createVerificationToken(data: VerificationToken): Promise<VerificationToken & { hashedIp: string }> {
3230
const hashedIp = await getHashedUserIpFromHeaders();
3331

3432
const token = await db.verificationToken.create({
@@ -43,18 +41,18 @@ const adapter = {
4341
if ('id' in token) {
4442
delete (token as any).id;
4543
}
46-
if ('hashedIp' in token) {
47-
delete (token as any).hashedIp;
48-
}
4944

5045
return token;
5146
},
5247
// Follow PrismaAdapter pattern of removing id
53-
createUser: ({ id, ...data }: AdapterUser) => {
48+
createUser: (data: AdapterUser) => {
5449
const userData = {
5550
...data,
5651
name: data.name || 'your pretty fake name',
5752
};
53+
if ('id' in userData) {
54+
delete (userData as any).id;
55+
}
5856

5957
return db.user.create({
6058
data: userData,

components/access-control/RoleGate.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { UserRole } from '@prisma/client';
33
import { FormError } from '@/components/forms/messages/FormError';
44
import { currentSessionRole } from '@/lib/auth/auth-utils';
55

6+
import type { ReactNode } from 'react';
7+
68
interface RoleGateProps {
7-
children: React.ReactNode;
9+
children: ReactNode;
810
allowedRole: UserRole;
911
}
1012

components/auth/buttons/LoginButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { useRouter } from 'next/navigation';
55
import { LoginForm } from '@/components/auth/forms/LoginForm';
66
import { Dialog, DialogContent, DialogTrigger } from '@/components/ui/dialog';
77

8+
import type { ReactNode } from 'react';
9+
810
interface LoginButtonProps {
9-
children: React.ReactNode;
11+
children: ReactNode;
1012
mode?: 'modal' | 'redirect';
1113
asChild?: boolean;
1214
}

components/auth/shared/CardWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { SocialButtons } from '@/components/auth/buttons/SocialButtons';
55
import { AuthFormHeader } from '@/components/auth/shared/AuthFormHeader';
66
import { Card, CardContent, CardFooter, CardHeader } from '@/components/ui/card';
77

8+
import type { ReactNode } from 'react';
9+
810
interface CardWrapperProps {
9-
children: React.ReactNode;
11+
children: ReactNode;
1012
headerLabel: string;
1113
backButtonLabel: string;
1214
backButtonHref: string;

0 commit comments

Comments
 (0)