Skip to content

Commit

Permalink
Okk
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Mar 31, 2024
1 parent c61deb1 commit 84b35b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/middleware/00.start.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from '@prisma/client'
import { services } from '../services';

declare module 'h3' {
interface H3EventContext {
Expand All @@ -7,6 +8,5 @@ declare module 'h3' {
}

export default defineEventHandler(async (event) => {
const prisma = new PrismaClient()
event.context.prisma = prisma
event.context.prisma = services.prisma
})
4 changes: 4 additions & 0 deletions server/plugins/startup.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import { PrismaClient } from "@prisma/client"
import { services } from "../services"

export default defineNitroPlugin(async (nuxtApp) => {
services.prisma = new PrismaClient()
})
7 changes: 7 additions & 0 deletions server/services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { PrismaClient } from "@prisma/client";

class Services {
prisma!: PrismaClient;
}

export const services = new Services()

0 comments on commit 84b35b3

Please sign in to comment.