Skip to content

Commit

Permalink
refactor: Fix formatting in middleware.ts, route.ts, loading.tsx, and…
Browse files Browse the repository at this point in the history
… use-system-theme.ts

feat: Add next-auth middleware and configure profile route

setup env

add nextui

Delete middleware.ts

Add next-auth type declaration
  • Loading branch information
iceship committed Sep 20, 2024
1 parent 2246dc7 commit c2a5bc7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/app/guestbook/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Card, CardBody } from "@nextui-org/react";

export default function Guestbook() {
return (
<Card className="max-w-d mx-auto mt-4">
<CardBody>
<h1>Guestbook</h1>
<p>Leave a message for the owner of this guestbook.</p>
</CardBody>
</Card>
);
}
1 change: 0 additions & 1 deletion src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import requireAuth from "@/utils/require-auth";
export default async function Profile() {
await requireAuth();
const session = (await getServerSession(options))!;

return (
<Card className="mx-auto mt-4 max-w-md">
<CardBody>
Expand Down
6 changes: 6 additions & 0 deletions src/config/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ const options: NextAuthOptions = {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
adapter: DrizzleAdapter(db),
callbacks: {
session({ session, user }) {
session.user.id = user.id;
return session;
},
},
providers: [
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
Expand Down
4 changes: 3 additions & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import postgres from "postgres";

import { env } from "@/env/server";

import * as schema from "./schema/index";

export const client = postgres(env.DATABASE_URL, {
max: env.DB_MIGRATING ? 1 : undefined,
});
const db = drizzle(client);
const db = drizzle(client, { schema });

export default db;
3 changes: 0 additions & 3 deletions src/middleware.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/types/next-auth.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { DefaultSession } from "next-auth";

declare module "next-auth" {
interface Session {
user: {
id: string;
} & DefaultSession["user"];
}
}

0 comments on commit c2a5bc7

Please sign in to comment.