mirror of https://github.com/ghostfolio/ghostfolio
				
				
			
							committed by
							
								
								GitHub
							
						
					
				
				 5 changed files with 37 additions and 10 deletions
			
			
		@ -1,6 +1,20 @@ | 
				
			|||
import { ExchangeRateDataService } from '@ghostfolio/api/services/exchange-rate-data.service'; | 
				
			|||
import { PrismaService } from '@ghostfolio/api/services/prisma.service'; | 
				
			|||
import { Controller } from '@nestjs/common'; | 
				
			|||
 | 
				
			|||
@Controller() | 
				
			|||
export class AppController { | 
				
			|||
  public constructor() {} | 
				
			|||
  public constructor( | 
				
			|||
    private readonly exchangeRateDataService: ExchangeRateDataService, | 
				
			|||
    private readonly prismaService: PrismaService | 
				
			|||
  ) { | 
				
			|||
    this.initialize(); | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  private async initialize() { | 
				
			|||
    try { | 
				
			|||
      await this.prismaService.$connect(); | 
				
			|||
      await this.exchangeRateDataService.initialize(); | 
				
			|||
    } catch {} | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
@ -1,15 +1,25 @@ | 
				
			|||
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; | 
				
			|||
import { | 
				
			|||
  Injectable, | 
				
			|||
  Logger, | 
				
			|||
  OnModuleDestroy, | 
				
			|||
  OnModuleInit | 
				
			|||
} from '@nestjs/common'; | 
				
			|||
import { PrismaClient } from '@prisma/client'; | 
				
			|||
 | 
				
			|||
@Injectable() | 
				
			|||
export class PrismaService | 
				
			|||
  extends PrismaClient | 
				
			|||
  implements OnModuleInit, OnModuleDestroy { | 
				
			|||
  async onModuleInit() { | 
				
			|||
    await this.$connect(); | 
				
			|||
  implements OnModuleInit, OnModuleDestroy | 
				
			|||
{ | 
				
			|||
  public async onModuleInit() { | 
				
			|||
    try { | 
				
			|||
      await this.$connect(); | 
				
			|||
    } catch (error) { | 
				
			|||
      Logger.error(error, 'PrismaService'); | 
				
			|||
    } | 
				
			|||
  } | 
				
			|||
 | 
				
			|||
  async onModuleDestroy() { | 
				
			|||
  public async onModuleDestroy() { | 
				
			|||
    await this.$disconnect(); | 
				
			|||
  } | 
				
			|||
} | 
				
			|||
 | 
				
			|||
					Loading…
					
					
				
		Reference in new issue