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'; |
import { Controller } from '@nestjs/common'; |
||||
|
|
||||
@Controller() |
@Controller() |
||||
export class AppController { |
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'; |
import { PrismaClient } from '@prisma/client'; |
||||
|
|
||||
@Injectable() |
@Injectable() |
||||
export class PrismaService |
export class PrismaService |
||||
extends PrismaClient |
extends PrismaClient |
||||
implements OnModuleInit, OnModuleDestroy { |
implements OnModuleInit, OnModuleDestroy |
||||
async onModuleInit() { |
{ |
||||
await this.$connect(); |
public async onModuleInit() { |
||||
|
try { |
||||
|
await this.$connect(); |
||||
|
} catch (error) { |
||||
|
Logger.error(error, 'PrismaService'); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
async onModuleDestroy() { |
public async onModuleDestroy() { |
||||
await this.$disconnect(); |
await this.$disconnect(); |
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue