feat: onboarding & profile edition (#507)
* feat: wip onboarding * fix: generate graphql front * wip: onboarding * feat: login/register and edit profile * fix: unused import * fix: test * Use DEBUG_MODE instead of STAGE and mute typescript depth exceed errors * Fix seeds * Fix onboarding when coming from google * Fix * Fix lint * Fix ci * Fix tests --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import {
|
||||
INestApplication,
|
||||
Injectable,
|
||||
Logger,
|
||||
OnModuleInit,
|
||||
} from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { createPrismaQueryEventHandler } from 'prisma-query-log';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
// TODO: Check if this is still needed
|
||||
if (!global.prisma) {
|
||||
global.prisma = new PrismaClient();
|
||||
}
|
||||
@@ -8,6 +16,36 @@ export default global.prisma;
|
||||
|
||||
@Injectable()
|
||||
export class PrismaService extends PrismaClient implements OnModuleInit {
|
||||
private readonly logger = new Logger(PrismaService.name);
|
||||
|
||||
constructor(private readonly environmentService: EnvironmentService) {
|
||||
const debugMode = environmentService.getDebugMode();
|
||||
super({
|
||||
errorFormat: 'minimal',
|
||||
log: debugMode
|
||||
? [
|
||||
{
|
||||
level: 'query',
|
||||
emit: 'event',
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
});
|
||||
|
||||
if (debugMode) {
|
||||
const logHandler = createPrismaQueryEventHandler({
|
||||
logger: (query: string) => {
|
||||
this.logger.log(query, 'PrismaClient');
|
||||
},
|
||||
format: false,
|
||||
colorQuery: '\u001B[96m',
|
||||
colorParameter: '\u001B[90m',
|
||||
});
|
||||
|
||||
this.$on('query' as any, logHandler);
|
||||
}
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
await this.$connect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user