Closed ethan0905 closed 1 year ago
Working on securing the app from SQL injection.
Here is a quick example : We handle the security inside the backend/src/prisma/prisma.service.ts :
import { Injectable } from '@nestjs/common'; import { PrismaClient } from '@prisma/client'; @Injectable() export class PrismaService { prisma: PrismaClient; constructor() { this.prisma = new PrismaClient(); } async onModuleDestroy() { await this.prisma.$disconnect(); } }
And we call the @Injectable decorator before any class we export:
import { Injectable } from '@nestjs/common'; import { PrismaService } from './prisma.service'; import { User } from '@prisma/client'; @Injectable() // here you must add your @Injectable decorator export class UserService { constructor(private prisma: PrismaService) {} async getUserById(id: number): Promise<User> { [...] } async createUser(name: string, email: string, password: string): Promise<User> { [...] } }
Working on securing the app from SQL injection.
Here is a quick example : We handle the security inside the backend/src/prisma/prisma.service.ts :
And we call the @Injectable decorator before any class we export: