Skip to content

Commit

Permalink
fix: update sample with prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony133 committed Jan 3, 2024
1 parent 3da2731 commit e37188c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
57 changes: 45 additions & 12 deletions sample/012-prisma-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sample/012-prisma-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@nestjs/platform-express": "10.3.0",
"@nestjs/terminus": "10.2.0",
"@prisma/client": "5.7.1",
"prisma": "4.16.2",
"prisma": "^5.7.1",
"reflect-metadata": "0.1.14",
"rxjs": "7.8.1"
},
Expand Down
3 changes: 3 additions & 0 deletions sample/012-prisma-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { AppModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);

app.enableShutdownHooks();

await app.listen(3000);
}
bootstrap();
8 changes: 1 addition & 7 deletions sample/012-prisma-app/src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { Injectable, OnModuleInit } 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();
});
}
}

0 comments on commit e37188c

Please sign in to comment.