-
Notifications
You must be signed in to change notification settings - Fork 9
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
ee408ee
commit 4f057aa
Showing
10 changed files
with
69 additions
and
14 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,5 @@ | ||
DATABASE_URL="" | ||
AUTH_SECRET="" | ||
HOST_STATUS="" | ||
AUTH_GOOGLE_ID="" | ||
AUTH_GOOGLE_SECRET="" |
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 |
---|---|---|
|
@@ -9,3 +9,5 @@ node_modules | |
!.env.example | ||
vite.config.js.timestamp-* | ||
vite.config.ts.timestamp-* | ||
google-credentials. | ||
.vscode |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { sequence } from '@sveltejs/kit/hooks'; | ||
import { handle as authHandle } from '$lib/auth/auth'; | ||
|
||
export const handle = sequence(authHandle); |
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,21 @@ | ||
import { DefaultSession, SvelteKitAuth, SvelteKitAuthConfig } from '@auth/sveltekit'; | ||
import { PrismaAdapter } from '@auth/prisma-adapter'; | ||
import Google from '@auth/sveltekit/providers/google'; | ||
import { db } from '$lib/db/db'; | ||
|
||
const authOptions:SvelteKitAuthConfig = { | ||
adapter: PrismaAdapter(db), | ||
providers: [Google], | ||
callbacks: { | ||
async session({ session, user, token }) { | ||
const sess = {} as DefaultSession; | ||
|
||
sess.expires = session.expires; | ||
sess.user = user; | ||
|
||
return sess; | ||
} | ||
} | ||
}; | ||
|
||
export const { handle, signIn, signOut } = SvelteKitAuth(authOptions); |
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,15 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import { env } from '$lib/env'; | ||
|
||
const createPrismaClient = () => | ||
new PrismaClient({ | ||
log: env.HOST_STATUS === 'development' ? ['query', 'error', 'warn'] : ['error'] | ||
}); | ||
|
||
const globalForPrisma = globalThis as unknown as { | ||
prisma: ReturnType<typeof createPrismaClient> | undefined; | ||
}; | ||
|
||
export const db = globalForPrisma.prisma ?? createPrismaClient(); | ||
|
||
if (env.HOST_STATUS !== 'production') globalForPrisma.prisma = db; |
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 @@ | ||
import { dev } from "$app/environment" | ||
|
||
export const env = { | ||
DATABASE_URL: process.env.DATABASE_URL, | ||
HOST_STATUS: process.env.HOST_STATUS || dev ? "development" : "production", | ||
AUTH_GOOGLE_ID: process.env.AUTH_GOOGLE_ID, | ||
AUTH_GOOGLE_SECRET: process.env.AUTH_GOOGLE_SECRET | ||
}; |
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 @@ | ||
export const load = async (event:any) => { | ||
const session = await event.locals.auth(); | ||
|
||
return { | ||
session | ||
}; | ||
}; |