chore: added prisma module

This commit is contained in:
ankitsridhar16
2022-12-07 20:52:31 +05:30
parent 9487348ba8
commit 06ef17048a
5 changed files with 32 additions and 3 deletions

View File

@@ -11,8 +11,8 @@ RUN npm i -g pnpm
# Prisma bits
#COPY prisma ./
#RUN pnpx prisma generate
COPY prisma ./
RUN pnpx prisma generate
COPY . .

View File

@@ -4,7 +4,7 @@ services:
build: .
environment:
- PRODUCTION=false
- DATABASE_URL=postgresql://postgres:testpass@dev-db:5432/hoppscotch
- DATABASE_URL=postgresql://postgres:testpass@dev-db:5432/hoppscotch?connect_timeout=300
- PORT=3000
# volumes:
# - .:/usr/src/app

View File

@@ -26,11 +26,13 @@
"@nestjs/core": "^9.2.1",
"@nestjs/graphql": "^10.1.6",
"@nestjs/platform-express": "^9.2.1",
"@prisma/client": "^4.7.1",
"apollo-server-express": "^3.11.1",
"graphql": "^15.5.0",
"graphql-redis-subscriptions": "^2.5.0",
"graphql-subscriptions": "^2.0.0",
"ioredis": "^5.2.4",
"prisma": "^4.7.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.6.0"

View File

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

View File

@@ -0,0 +1,19 @@
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
import { PrismaClient } from '@prisma/client/scripts/default-index';
@Injectable()
export class PrismaService
extends PrismaClient
implements OnModuleInit, OnModuleDestroy
{
constructor() {
super();
}
async onModuleInit() {
await this.$connect();
}
async onModuleDestroy() {
await this.$disconnect();
}
}