-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: enables app directory now that is stable, better documentation, updates dependencies
- Loading branch information
Showing
18 changed files
with
756 additions
and
515 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Menu from '@/components/menu' | ||
import { Metadata } from 'next' | ||
import { Session } from 'next-auth' | ||
import { headers } from 'next/dist/client/components/headers' | ||
import ClientSessionProvider from '../components/auth/session-provider' | ||
import '../global.css' | ||
|
||
export const metadata: Metadata = { | ||
title: '🍃 Nextwind', | ||
description: | ||
'Introducing a powerful and efficient full- stack web development starter project built with TypeScript, Next.JS, Supabase, PostgreSQL, TailwindCSS, and Zustand!', | ||
} | ||
|
||
export interface DashboardLayoutProps { | ||
children: React.ReactNode | ||
} | ||
|
||
export async function getSession(cookie: string): Promise<Session | null> { | ||
const response = await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`, { | ||
headers: { cookie }, | ||
}) | ||
|
||
if (!response?.ok) { | ||
return null | ||
} | ||
|
||
const session = await response.json() | ||
return Object.keys(session).length > 0 ? session : null | ||
} | ||
|
||
export default async function Layout({ children }: { children: React.ReactNode; props?: any }) { | ||
const session = await getSession(headers().get('cookie') ?? '') | ||
|
||
return ( | ||
<html> | ||
<head /> | ||
<body className='bg-[#081113] text-gray-300'> | ||
<ClientSessionProvider session={session}> | ||
<Menu /> | ||
<div className='container grid mx-auto max-w-5xl h-screen'>{children}</div> | ||
</ClientSessionProvider> | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use client' | ||
|
||
import { Session } from 'next-auth' | ||
import { SessionProvider } from 'next-auth/react' | ||
|
||
export interface AuthContextProps { | ||
children: React.ReactNode | ||
session: Session | ||
} | ||
|
||
export default function AuthContext({ children }: AuthContextProps) { | ||
return <SessionProvider>{children}</SessionProvider> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use client' | ||
|
||
import { SessionProvider, SessionProviderProps } from 'next-auth/react' | ||
|
||
export default function ClientSessionProvider(props: SessionProviderProps) { | ||
return <SessionProvider {...props} /> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
/// <reference types="next/navigation-types/compat/navigation" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
create schema if not exists "next_auth"; | ||
|
||
create table "next_auth"."accounts" ( | ||
"id" uuid not null default uuid_generate_v4(), | ||
"type" text not null, | ||
"provider" text not null, | ||
"providerAccountId" text not null, | ||
"refresh_token" text, | ||
"access_token" text, | ||
"expires_at" bigint, | ||
"token_type" text, | ||
"scope" text, | ||
"id_token" text, | ||
"session_state" text, | ||
"oauth_token_secret" text, | ||
"oauth_token" text, | ||
"userId" uuid, | ||
"refresh_token_expires_in" bigint | ||
); | ||
|
||
|
||
alter table "next_auth"."accounts" enable row level security; | ||
|
||
create table "next_auth"."sessions" ( | ||
"id" uuid not null default uuid_generate_v4(), | ||
"expires" timestamp with time zone not null, | ||
"sessionToken" text not null, | ||
"userId" uuid | ||
); | ||
|
||
|
||
alter table "next_auth"."sessions" enable row level security; | ||
|
||
create table "next_auth"."users" ( | ||
"id" uuid not null default uuid_generate_v4(), | ||
"name" text, | ||
"email" text, | ||
"emailVerified" timestamp with time zone, | ||
"image" text, | ||
"refresh_token_expires_in" timestamp without time zone | ||
); | ||
|
||
|
||
alter table "next_auth"."users" enable row level security; | ||
|
||
create table "next_auth"."verification_tokens" ( | ||
"identifier" text, | ||
"token" text not null, | ||
"expires" timestamp with time zone not null | ||
); | ||
|
||
|
||
alter table "next_auth"."verification_tokens" enable row level security; | ||
|
||
CREATE UNIQUE INDEX accounts_pkey ON next_auth.accounts USING btree (id); | ||
|
||
CREATE UNIQUE INDEX email_unique ON next_auth.users USING btree (email); | ||
|
||
CREATE UNIQUE INDEX provider_unique ON next_auth.accounts USING btree (provider, "providerAccountId"); | ||
|
||
CREATE UNIQUE INDEX sessions_pkey ON next_auth.sessions USING btree (id); | ||
|
||
CREATE UNIQUE INDEX sessiontoken_unique ON next_auth.sessions USING btree ("sessionToken"); | ||
|
||
CREATE UNIQUE INDEX token_identifier_unique ON next_auth.verification_tokens USING btree (token, identifier); | ||
|
||
CREATE UNIQUE INDEX users_pkey ON next_auth.users USING btree (id); | ||
|
||
CREATE UNIQUE INDEX verification_tokens_pkey ON next_auth.verification_tokens USING btree (token); | ||
|
||
alter table "next_auth"."accounts" add constraint "accounts_pkey" PRIMARY KEY using index "accounts_pkey"; | ||
|
||
alter table "next_auth"."sessions" add constraint "sessions_pkey" PRIMARY KEY using index "sessions_pkey"; | ||
|
||
alter table "next_auth"."users" add constraint "users_pkey" PRIMARY KEY using index "users_pkey"; | ||
|
||
alter table "next_auth"."verification_tokens" add constraint "verification_tokens_pkey" PRIMARY KEY using index "verification_tokens_pkey"; | ||
|
||
alter table "next_auth"."accounts" add constraint "accounts_userId_fkey" FOREIGN KEY ("userId") REFERENCES next_auth.users(id) ON DELETE CASCADE not valid; | ||
|
||
alter table "next_auth"."accounts" validate constraint "accounts_userId_fkey"; | ||
|
||
alter table "next_auth"."accounts" add constraint "provider_unique" UNIQUE using index "provider_unique"; | ||
|
||
alter table "next_auth"."sessions" add constraint "sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES next_auth.users(id) ON DELETE CASCADE not valid; | ||
|
||
alter table "next_auth"."sessions" validate constraint "sessions_userId_fkey"; | ||
|
||
alter table "next_auth"."sessions" add constraint "sessiontoken_unique" UNIQUE using index "sessiontoken_unique"; | ||
|
||
alter table "next_auth"."users" add constraint "email_unique" UNIQUE using index "email_unique"; | ||
|
||
alter table "next_auth"."verification_tokens" add constraint "token_identifier_unique" UNIQUE using index "token_identifier_unique"; | ||
|
||
set check_function_bodies = off; | ||
|
||
CREATE OR REPLACE FUNCTION next_auth.uid() | ||
RETURNS uuid | ||
LANGUAGE sql | ||
STABLE | ||
AS $function$ | ||
select | ||
coalesce( | ||
nullif(current_setting('request.jwt.claim.sub', true), ''), | ||
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub') | ||
)::uuid | ||
$function$ | ||
; |
Oops, something went wrong.