Skip to content

Commit

Permalink
prisma 数据库连接优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghao1993 committed Sep 4, 2024
1 parent 292c571 commit 63213ce
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 7 deletions.
2 changes: 0 additions & 2 deletions lib/auth_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const authOptions: AuthOptions = {
},
async profile(profile) {
try {
await prisma.$connect();
const existingUser = await prisma.user.findUnique({
where: { email: profile.email },
});
Expand Down Expand Up @@ -50,7 +49,6 @@ export const authOptions: AuthOptions = {
},
});

prisma.$disconnect();
return res as any;
} catch (e: any) {
console.log(e.message);
Expand Down
2 changes: 0 additions & 2 deletions lib/fetch_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ export function responseHandler<T>(
code = BusinessCode.normal,
message = "success"
) {
prisma.$disconnect();

return NextResponse.json({ message, data, code }, { status });
}
3 changes: 0 additions & 3 deletions posts/prisma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ export const authOptions: AuthOptions = {
},
async profile(profile) {
try {
// 连接
await prisma.$connect();
// 查询是否有
const existingUser = await prisma.user.findUnique({
where: { email: profile.email },
Expand Down Expand Up @@ -184,7 +182,6 @@ export const authOptions: AuthOptions = {
},
});

prisma.$disconnect();
return res as any;
} catch (e: any) {
console.log(e.message);
Expand Down

0 comments on commit 63213ce

Please sign in to comment.