@takentrade/takentrade-libs 1.2.66 → 1.2.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { INestApplication, OnModuleInit } from '@nestjs/common';
1
+ import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
2
  import { PrismaClient } from '@prisma/client';
3
- export declare class PrismaService extends PrismaClient implements OnModuleInit {
3
+ export declare class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
4
4
  onModuleInit(): Promise<void>;
5
- enableShutdownHooks(app: INestApplication): void;
5
+ onModuleDestroy(): Promise<void>;
6
6
  }
@@ -11,12 +11,16 @@ const common_1 = require("@nestjs/common");
11
11
  const client_1 = require("@prisma/client");
12
12
  let PrismaService = class PrismaService extends client_1.PrismaClient {
13
13
  async onModuleInit() {
14
- await this.$connect();
14
+ try {
15
+ await this.$connect();
16
+ }
17
+ catch (error) {
18
+ common_1.Logger.error('Failed to connect to database', error);
19
+ process.exit(1);
20
+ }
15
21
  }
16
- enableShutdownHooks(app) {
17
- process.on('beforeExit', () => {
18
- app.close().catch(console.error);
19
- });
22
+ async onModuleDestroy() {
23
+ await this.$disconnect();
20
24
  }
21
25
  };
22
26
  exports.PrismaService = PrismaService;