generated from warmachine028/github-super-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef9b94c
commit 212998a
Showing
6 changed files
with
170 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
POSTGRES_URL=<Your POSTGRES_URL> | ||
POSTGRES_PRISMA_URL=<Your POSTGRES_PRISMA_URL> | ||
POSTGRES_URL_NO_SSL=<Your POSTGRES_URL_NO_SSL> | ||
POSTGRES_URL_NON_POOLING=<Your POSTGRES_URL_NON_POOLING> | ||
POSTGRES_USER=<Your POSTGRES_USER> | ||
POSTGRES_HOST=<Your POSTGRES_HOST> | ||
POSTGRES_PASSWORD=<Your POSTGRES_PASSWORD> | ||
POSTGRES_DATABASE=<Your POSTGRES_DATABASE> |
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,65 +1,66 @@ | ||
{ | ||
"dependencies": { | ||
"@hookform/resolvers": "^3.9.0", | ||
"@lucia-auth/adapter-prisma": "^4.0.1", | ||
"@prisma/client": "^5.18.0", | ||
"@radix-ui/react-label": "^2.1.0", | ||
"@radix-ui/react-slot": "^1.1.0", | ||
"@radix-ui/react-tabs": "^1.1.0", | ||
"@radix-ui/react-toast": "^1.2.1", | ||
"@radix-ui/react-tooltip": "^1.1.2", | ||
"@tanstack/react-query": "^5.52.1", | ||
"@tanstack/react-query-devtools": "^5.52.1", | ||
"@tiptap/extension-placeholder": "^2.6.6", | ||
"@tiptap/pm": "^2.6.6", | ||
"@tiptap/react": "^2.6.6", | ||
"@tiptap/starter-kit": "^2.6.6", | ||
"@uploadthing/react": "^6.7.2", | ||
"arctic": "^1.9.2", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.1", | ||
"date-fns": "^3.6.0", | ||
"ky": "^1.7.1", | ||
"lucia": "^3.2.0", | ||
"lucide-react": "^0.435.0", | ||
"next": "15.0.0-rc.0", | ||
"next-themes": "^0.3.0", | ||
"prisma": "^5.18.0", | ||
"react": "19.0.0-rc-f994737d14-20240522", | ||
"react-cropper": "^2.3.3", | ||
"react-dom": "19.0.0-rc-f994737d14-20240522", | ||
"react-hook-form": "^7.53.0", | ||
"react-image-file-resizer": "^0.4.8", | ||
"react-intersection-observer": "^9.13.0", | ||
"react-linkify-it": "^1.0.8", | ||
"stream-chat": "^8.39.0", | ||
"stream-chat-react": "^11.23.7", | ||
"tailwind-merge": "^2.5.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"uploadthing": "^6.13.2", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^22", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"eslint": "^9", | ||
"eslint-config-next": "15.0.0-rc.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"postcss": "^8", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-packagejson": "^2.5.2", | ||
"prettier-plugin-tailwindcss": "^0.6.6", | ||
"tailwindcss": "^3.4.1", | ||
"typescript": "^5" | ||
}, | ||
"name": "next-book", | ||
"private": true, | ||
"scripts": { | ||
"build": "next build", | ||
"dev": "next dev --turbo", | ||
"lint": "next lint", | ||
"start": "next start" | ||
}, | ||
"version": "0.1.0" | ||
"dependencies": { | ||
"@hookform/resolvers": "^3.9.0", | ||
"@lucia-auth/adapter-prisma": "^4.0.1", | ||
"@prisma/client": "^5.18.0", | ||
"@radix-ui/react-label": "^2.1.0", | ||
"@radix-ui/react-slot": "^1.1.0", | ||
"@radix-ui/react-tabs": "^1.1.0", | ||
"@radix-ui/react-toast": "^1.2.1", | ||
"@radix-ui/react-tooltip": "^1.1.2", | ||
"@tanstack/react-query": "^5.52.1", | ||
"@tanstack/react-query-devtools": "^5.52.1", | ||
"@tiptap/extension-placeholder": "^2.6.6", | ||
"@tiptap/pm": "^2.6.6", | ||
"@tiptap/react": "^2.6.6", | ||
"@tiptap/starter-kit": "^2.6.6", | ||
"@uploadthing/react": "^6.7.2", | ||
"arctic": "^1.9.2", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.1", | ||
"date-fns": "^3.6.0", | ||
"ky": "^1.7.1", | ||
"lucia": "^3.2.0", | ||
"lucide-react": "^0.435.0", | ||
"next": "15.0.0-rc.0", | ||
"next-themes": "^0.3.0", | ||
"prisma": "^5.18.0", | ||
"react": "19.0.0-rc-f994737d14-20240522", | ||
"react-cropper": "^2.3.3", | ||
"react-dom": "19.0.0-rc-f994737d14-20240522", | ||
"react-hook-form": "^7.53.0", | ||
"react-image-file-resizer": "^0.4.8", | ||
"react-intersection-observer": "^9.13.0", | ||
"react-linkify-it": "^1.0.8", | ||
"stream-chat": "^8.39.0", | ||
"stream-chat-react": "^11.23.7", | ||
"tailwind-merge": "^2.5.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"uploadthing": "^6.13.2", | ||
"zod": "^3.23.8" | ||
}, | ||
"license":"MIT", | ||
"devDependencies": { | ||
"@types/node": "^22", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"eslint": "^9", | ||
"eslint-config-next": "15.0.0-rc.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"postcss": "^8", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-packagejson": "^2.5.2", | ||
"prettier-plugin-tailwindcss": "^0.6.6", | ||
"tailwindcss": "^3.4.1", | ||
"typescript": "^5" | ||
}, | ||
"name": "next-book", | ||
"private": true, | ||
"scripts": { | ||
"build": "next build", | ||
"dev": "next dev --turbo", | ||
"lint": "next lint", | ||
"start": "next start" | ||
}, | ||
"version": "0.1.0" | ||
} |
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,69 @@ | ||
import { Lucia, Session, User } from 'lucia' | ||
import { PrismaAdapter } from '@lucia-auth/adapter-prisma' | ||
import prisma from '@/lib/prisma' | ||
import { cache } from 'react' | ||
import { cookies } from 'next/headers' | ||
|
||
const adapter = new PrismaAdapter(prisma.session, prisma.user) | ||
|
||
interface DatabaseUserAttributes { | ||
id: string | ||
userName: string | ||
displayName: string | ||
avatarUrl: String | null | ||
googleId: string | null | ||
} | ||
|
||
declare module 'lucia' { | ||
interface Register { | ||
Lucia: typeof lucia | ||
DatabaseUserAttributes: DatabaseUserAttributes | ||
} | ||
} | ||
|
||
export const lucia = new Lucia(adapter, { | ||
sessionCookie: { | ||
expires: false, | ||
attributes: { | ||
secure: process.env.NODE_ENV === 'production' | ||
} | ||
}, | ||
getUserAttributes({ id, userName, displayName, avatarUrl, googleId }: DatabaseUserAttributes) { | ||
return { | ||
id, | ||
userName, | ||
displayName, | ||
avatarUrl, | ||
googleId | ||
} | ||
} | ||
}) | ||
|
||
export const validateRequest = cache( | ||
async (): Promise<{ user: User; session: Session } | { user: null; session: null }> => { | ||
const sessionId = cookies().get(lucia.sessionCookieName)?.value ?? null | ||
if (!sessionId) { | ||
return { | ||
user: null, | ||
session: null | ||
} | ||
} | ||
const result = await lucia.validateSession(sessionId) | ||
try { | ||
if (result.session?.fresh) { | ||
const sessionCookie = lucia.createSessionCookie(result.session.id) | ||
const { name, value, attributes } = sessionCookie | ||
cookies().set(name, value, attributes) | ||
} | ||
if (!result.session) { | ||
const sessionCookie = lucia.createBlankSessionCookie() | ||
const { name, value, attributes } = sessionCookie | ||
|
||
cookies().set(name, value, attributes) | ||
} | ||
} catch (error) { | ||
console.log(error) | ||
} | ||
return result | ||
} | ||
) |
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