feat: Implement Prisma PG adapter, refactor user and agent profiles in schema, and add database seeding.

This commit is contained in:
pradeepkumar
2025-12-19 01:15:19 +05:30
parent c1fcf32eb5
commit 1812fd3c98
8 changed files with 867 additions and 1143 deletions

View File

@@ -3,7 +3,7 @@ import { ValidationPipe, Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import helmet from 'helmet';
import * as cookieParser from 'cookie-parser';
import cookieParser from 'cookie-parser';
import { AppModule } from './app.module';
import { AllExceptionsFilter } from './common/filters';
import { TransformInterceptor } from './common/interceptors';

View File

@@ -1,18 +1,29 @@
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg';
import { Pool } from 'pg';
@Injectable()
export class PrismaService
extends PrismaClient
implements OnModuleInit, OnModuleDestroy
{
private pool: Pool;
constructor() {
const connectionString = process.env.DATABASE_URL;
const pool = new Pool({ connectionString });
const adapter = new PrismaPg(pool);
super({
adapter,
log:
process.env.NODE_ENV === 'development'
? ['query', 'info', 'warn', 'error']
: ['error'],
});
this.pool = pool;
}
async onModuleInit() {
@@ -21,6 +32,7 @@ export class PrismaService
async onModuleDestroy() {
await this.$disconnect();
await this.pool.end();
}
async cleanDatabase() {