Skip to content

Instantly share code, notes, and snippets.

View snelusha's full-sized avatar
🔥
Hacking

Sithija Nelusha Silva snelusha

🔥
Hacking
View GitHub Profile
@IzumiSy
IzumiSy / prismaAdapter.ts
Created June 7, 2023 16:02
PrismaAdapter for NextAuth with all camelCase naming convention
import { Adapter, AdapterSession, AdapterUser } from 'next-auth/adapters'
import { PrismaClient } from '@prisma/client'
import { PrismaClientKnownRequestError } from '@prisma/client/runtime'
import { User, Session } from '@prisma/client'
// PrismaAdapter customized to have more cleaner naming consistency
// (From: https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-prisma/src/index.ts)
export function PrismaAdapter(p: PrismaClient): Adapter {
const toAdapterUser = (user: User): AdapterUser => {
return {
# The MIT License
Copyright (c) 2020, Alessandro Segala
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: