Refactor code structure and dependencies
This commit is contained in:
12
src/middlewares/prisma-context.middleware.ts
Normal file
12
src/middlewares/prisma-context.middleware.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaContextMiddleware implements NestMiddleware {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
use(req: any, res: any, next: () => void) {
|
||||
req.prisma = this.prisma; // Attach Prisma client to request object
|
||||
next();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user