Some checks failed
ci/woodpecker/push/ci Pipeline failed
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
27 lines
760 B
TypeScript
27 lines
760 B
TypeScript
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from "@nestjs/common";
|
|
import { PrismaClient } from "@prisma/client";
|
|
|
|
/**
|
|
* Lightweight Prisma service for orchestrator ingestion persistence.
|
|
*/
|
|
@Injectable()
|
|
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
private readonly logger = new Logger(PrismaService.name);
|
|
|
|
constructor() {
|
|
super({
|
|
log: process.env.NODE_ENV === "development" ? ["warn", "error"] : ["error"],
|
|
});
|
|
}
|
|
|
|
async onModuleInit(): Promise<void> {
|
|
await this.$connect();
|
|
this.logger.log("Database connection established");
|
|
}
|
|
|
|
async onModuleDestroy(): Promise<void> {
|
|
await this.$disconnect();
|
|
this.logger.log("Database connection closed");
|
|
}
|
|
}
|