feat(server): init nestjs server (#1997)

Co-authored-by: himself65 <himself65@outlook.com>
This commit is contained in:
LongYinan
2023-04-18 11:24:44 +08:00
committed by GitHub
parent a92d0fff4a
commit 91c3040db7
28 changed files with 4191 additions and 17575 deletions

View File

@@ -0,0 +1,10 @@
import { Global, Module } from '@nestjs/common';
import { PrismaService } from './service';
@Global()
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}

View File

@@ -0,0 +1,16 @@
import type { INestApplication, OnModuleInit } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}
async enableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
await app.close();
});
}
}