diff --git a/packages/hoppscotch-backend/Dockerfile b/packages/hoppscotch-backend/Dockerfile index 7eb6d8331..48bc5a2c3 100644 --- a/packages/hoppscotch-backend/Dockerfile +++ b/packages/hoppscotch-backend/Dockerfile @@ -11,8 +11,8 @@ RUN npm i -g pnpm # Prisma bits -#COPY prisma ./ -#RUN pnpx prisma generate +COPY prisma ./ +RUN pnpx prisma generate COPY . . diff --git a/packages/hoppscotch-backend/docker-compose.yml b/packages/hoppscotch-backend/docker-compose.yml index eab1e473d..f4e51f3bd 100644 --- a/packages/hoppscotch-backend/docker-compose.yml +++ b/packages/hoppscotch-backend/docker-compose.yml @@ -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 diff --git a/packages/hoppscotch-backend/package.json b/packages/hoppscotch-backend/package.json index c603b4146..08a9aa4dc 100644 --- a/packages/hoppscotch-backend/package.json +++ b/packages/hoppscotch-backend/package.json @@ -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" diff --git a/packages/hoppscotch-backend/src/prisma/prisma.module.ts b/packages/hoppscotch-backend/src/prisma/prisma.module.ts new file mode 100644 index 000000000..953aa89d8 --- /dev/null +++ b/packages/hoppscotch-backend/src/prisma/prisma.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common/decorators'; +import { PrismaService } from './prisma.service'; + +@Module({ + providers: [PrismaService], + exports: [PrismaService], +}) +export class PrismaModule {} diff --git a/packages/hoppscotch-backend/src/prisma/prisma.service.ts b/packages/hoppscotch-backend/src/prisma/prisma.service.ts new file mode 100644 index 000000000..5b962c430 --- /dev/null +++ b/packages/hoppscotch-backend/src/prisma/prisma.service.ts @@ -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(); + } +}