feat: 搭建 NestJS 后端基础设施与 Prisma 数据模型

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Nixevol
2026-06-28 15:35:47 +08:00
co-authored by Cursor
parent 3e9ab08881
commit 9629597b1d
23 changed files with 8051 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
@Global()
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}
+16
View File
@@ -0,0 +1,16 @@
import { Injectable, OnModuleInit, OnModuleDestroy, Logger } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
private readonly logger = new Logger(PrismaService.name);
async onModuleInit(): Promise<void> {
await this.$connect();
this.logger.log('数据库已连接');
}
async onModuleDestroy(): Promise<void> {
await this.$disconnect();
}
}