mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 06:34:15 +00:00
feat: prisma, postgresql, and upgrade to auth.js@beta
This commit is contained in:
parent
54fee71491
commit
7b799405dc
12 changed files with 720 additions and 147 deletions
14
src/lib/auth.ts
Normal file
14
src/lib/auth.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import NextAuth from "next-auth";
|
||||
import Discord from "next-auth/providers/discord";
|
||||
import Github from "next-auth/providers/github";
|
||||
|
||||
import { PrismaAdapter } from "@auth/prisma-adapter";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
adapter: PrismaAdapter(prisma),
|
||||
providers: [Discord, Github],
|
||||
pages: {
|
||||
signIn: "/login",
|
||||
},
|
||||
});
|
||||
7
src/lib/prisma.ts
Normal file
7
src/lib/prisma.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma = globalForPrisma.prisma || new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
|
||||
Loading…
Add table
Add a link
Reference in a new issue