N
Neon2y ago
national-gold

Prisma Adapter error not connecting to db

I get this error message: ype 'import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/core/adapters").Adapter' is not assignable to type Types of property 'getAuthenticator' are incompatible. Type '((credentialID: string) => import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/core/types").Awaitable<import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/core/adapters").Ada...' is not assignable to type '((credentialID: string) => import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.27.0_nodemailer@6.9.13/node_modules/@auth/core/types").Awaitable<import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.27.0_nodemailer@6.9.13/node_modules/@auth/core/adapters").Ada...'. Type '(credentialID: string) => import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/core/types").Awaitable<import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/core/adapters").Adap...' is not assignable to type '(credentialID: string) => Type 'import("/Users/mehtabghuman/Desktop/ReZume/Rezume/node_modules/.pnpm/@auth+core@0.32.0_nodemailer@6.9.13/node_modules/@auth/c Type 'AdapterAuthenticator' is not assignable to type 'Awaitable<AdapterAuthenticator | null>'. Type . Types of property 'transports' are incompatible. Type 'string | null | undefined' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.ts(2322) (property) adapter?: Adapter | undefined
1 Reply
national-gold
national-goldOP2y ago
here is the code:
import { linkOAuthAccount } from "@/actions/auth"
import { getUserById } from "@/actions/user"
import { PrismaAdapter } from "@auth/prisma-adapter"
import NextAuth from "next-auth"

import { env } from "@/env.mjs"
import authConfig from "@/config/auth"
import { prisma } from "@/config/db"

export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
debug: env.NODE_ENV === "development",
pages: {
signIn: "/signin",
signOut: "/signout",
verifyRequest: "/signin/magic-link-signin",
},
secret: env.AUTH_SECRET,

events: {
async linkAccount({ user }) {
if (user.id) await linkOAuthAccount({ userId: user.id })
},
},
callbacks: {
jwt({ token, user }) {
if (user) token.role = user.role
return token
},
session({ session, token }) {
if (token.sub && session.user) {
session.user.id = token.sub
}

if (token.role && session.user) {
session.user.role = token.role as "USER" | "ADMIN"
}

return session
},
async signIn({ user, account }) {
if (!user.id) return false
if (account?.provider !== "credentials") return true

const existingUser = await getUserById({ id: user.id })

return !existingUser?.emailVerified ? false : true
},
},

adapter: PrismaAdapter(prisma),
session: { strategy: "jwt" },
...authConfig,
})
import { linkOAuthAccount } from "@/actions/auth"
import { getUserById } from "@/actions/user"
import { PrismaAdapter } from "@auth/prisma-adapter"
import NextAuth from "next-auth"

import { env } from "@/env.mjs"
import authConfig from "@/config/auth"
import { prisma } from "@/config/db"

export const {
handlers: { GET, POST },
auth,
signIn,
signOut,
} = NextAuth({
debug: env.NODE_ENV === "development",
pages: {
signIn: "/signin",
signOut: "/signout",
verifyRequest: "/signin/magic-link-signin",
},
secret: env.AUTH_SECRET,

events: {
async linkAccount({ user }) {
if (user.id) await linkOAuthAccount({ userId: user.id })
},
},
callbacks: {
jwt({ token, user }) {
if (user) token.role = user.role
return token
},
session({ session, token }) {
if (token.sub && session.user) {
session.user.id = token.sub
}

if (token.role && session.user) {
session.user.role = token.role as "USER" | "ADMIN"
}

return session
},
async signIn({ user, account }) {
if (!user.id) return false
if (account?.provider !== "credentials") return true

const existingUser = await getUserById({ id: user.id })

return !existingUser?.emailVerified ? false : true
},
},

adapter: PrismaAdapter(prisma),
session: { strategy: "jwt" },
...authConfig,
})

Did you find this page helpful?