Skip to content

How to inject custom provider? #904

Answered by manniL
uyloal asked this question in Q&A
Feb 3, 2023 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

You can use a nitro middleware and do sth. like:

import { PrismaClient } from '@prisma/client'

let prisma
export default defineEventHandler((event) => {
  if (!prisma) {
    prisma = new PrismaClient()
  }
  event.context.prisma = prisma
})

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@blasdfaa
Comment options

@manniL
Comment options

Answer selected by uyloal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants