Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

chore: cleaned up hopp-backend package and modified docker and docker-compose files

Balu Babuc5466edf7191
diff --git a/packages/hoppscotch-backend/.eslintrc.js b/packages/hoppscotch-backend/.eslintrc.js
index 8f5aedb71..259de13c7 100644
--- a/packages/hoppscotch-backend/.eslintrc.js
+++ b/packages/hoppscotch-backend/.eslintrc.js
@@ -2,7 +2,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
- tsconfigRootDir : __dirname,
+ tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
diff --git a/packages/hoppscotch-backend/.prettierrc b/packages/hoppscotch-backend/.prettierrc
index dcb72794f..a20502b7f 100644
--- a/packages/hoppscotch-backend/.prettierrc
+++ b/packages/hoppscotch-backend/.prettierrc
@@ -1,4 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
-}
\ No newline at end of file
+}
diff --git a/packages/hoppscotch-backend/Dockerfile b/packages/hoppscotch-backend/Dockerfile
index 48bc5a2c3..ab0c88f42 100644
--- a/packages/hoppscotch-backend/Dockerfile
+++ b/packages/hoppscotch-backend/Dockerfile
@@ -5,16 +5,11 @@ WORKDIR /usr/src/app
# # Install pnpm
RUN npm i -g pnpm
-# # NPM package install
-# COPY package*.json ./
-# RUN pnpm install
-
-
# Prisma bits
COPY prisma ./
RUN pnpx prisma generate
-
+# # NPM package install
COPY . .
RUN pnpm i
@@ -25,6 +20,4 @@ ENV APP_PORT=${PORT}
ENV DB_URL=${DATABASE_URL}
ENV PRODUCTION=true
-#ENV FB_SERVICE_KEY_PATH="secrets/fb-service-key.json"
-# CMD ["pnpm", "run", "start:dev"]
CMD ["pnpm", "run", "start"]
diff --git a/packages/hoppscotch-backend/docker-compose.yml b/packages/hoppscotch-backend/docker-compose.yml
index f4e51f3bd..9b22e6f75 100644
--- a/packages/hoppscotch-backend/docker-compose.yml
+++ b/packages/hoppscotch-backend/docker-compose.yml
@@ -6,8 +6,9 @@ services:
- PRODUCTION=false
- DATABASE_URL=postgresql://postgres:testpass@dev-db:5432/hoppscotch?connect_timeout=300
- PORT=3000
-# volumes:
-# - .:/usr/src/app
+ volumes:
+ - .:/usr/src/app
+ - /usr/src/app/node_modules/
depends_on:
- dev-db
ports:
diff --git a/packages/hoppscotch-backend/src/app.controller.spec.ts b/packages/hoppscotch-backend/src/app.controller.spec.ts
deleted file mode 100644
index d22f3890a..000000000
--- a/packages/hoppscotch-backend/src/app.controller.spec.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Test, TestingModule } from '@nestjs/testing';
-import { AppController } from './app.controller';
-import { AppService } from './app.service';
-
-describe('AppController', () => {
- let appController: AppController;
-
- beforeEach(async () => {
- const app: TestingModule = await Test.createTestingModule({
- controllers: [AppController],
- providers: [AppService],
- }).compile();
-
- appController = app.get<AppController>(AppController);
- });
-
- describe('root', () => {
- it('should return "Hello World!"', () => {
- expect(appController.getHello()).toBe('Hello World!');
- });
- });
-});
diff --git a/packages/hoppscotch-backend/src/app.controller.ts b/packages/hoppscotch-backend/src/app.controller.ts
deleted file mode 100644
index cce879ee6..000000000
--- a/packages/hoppscotch-backend/src/app.controller.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Controller, Get } from '@nestjs/common';
-import { AppService } from './app.service';
-
-@Controller()
-export class AppController {
- constructor(private readonly appService: AppService) {}
-
- @Get()
- getHello(): string {
- return this.appService.getHello();
- }
-}
diff --git a/packages/hoppscotch-backend/src/app.resolver.ts b/packages/hoppscotch-backend/src/app.resolver.ts
deleted file mode 100644
index f16f8b565..000000000
--- a/packages/hoppscotch-backend/src/app.resolver.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Query, Resolver } from '@nestjs/graphql';
-import { AppService } from './app.service';
-
-@Resolver((of) => String)
-export class AppResolver {
- constructor(private appService: AppService) {}
-
- @Query((returns) => String)
- async author() {
- return this.appService.getHello();
- }
-}
diff --git a/packages/hoppscotch-backend/src/app.service.ts b/packages/hoppscotch-backend/src/app.service.ts
deleted file mode 100644
index 927d7cca0..000000000
--- a/packages/hoppscotch-backend/src/app.service.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Injectable } from '@nestjs/common';
-
-@Injectable()
-export class AppService {
- getHello(): string {
- return 'Hello World!';
- }
-}
diff --git a/packages/hoppscotch-backend/src/main.ts b/packages/hoppscotch-backend/src/main.ts
index 5c4786c2a..98a2ff179 100644
--- a/packages/hoppscotch-backend/src/main.ts
+++ b/packages/hoppscotch-backend/src/main.ts
@@ -24,13 +24,6 @@ async function bootstrap() {
} else {
console.log('Enabling CORS with production settings');
- // HACK: Temporary fix for Liyas to work on production directly :P
- /*
- app.enableCors({
- origin: /hoppscotch\.io$/
- });
- */
-
app.enableCors({
origin: true,
});
diff --git a/packages/hoppscotch-backend/src/user/user.resolver.ts b/packages/hoppscotch-backend/src/user/user.resolver.ts
index cdbd63f31..d913be01d 100644
--- a/packages/hoppscotch-backend/src/user/user.resolver.ts
+++ b/packages/hoppscotch-backend/src/user/user.resolver.ts
@@ -6,20 +6,10 @@ import { GqlUser } from '../decorators/gql-user.decorator';
@Resolver(() => User)
export class UserResolver {
+ // TODO: remove the eslint-disable line below once dependencies are added to user.service file
// eslint-disable-next-line @typescript-eslint/no-empty-function
constructor() {}
- // Query
- // @Query(() => User, {
- // nullable: true,
- // description: 'Finds a user by their UID or null if no match',
- // deprecationReason:
- // 'Deprecated due to privacy concerns. Try to get the user from the context-relevant queries',
- // })
- // async user(@Args({ name: 'uid', type: () => ID }) uid: string): Promise<User | null> {
- // return this.userService.getUserForUID(uid);
- // }
-
@Query(() => User, {
description:
"Gives details of the user executing this query (pass Authorization 'Bearer' header)",
@@ -29,29 +19,12 @@ export class UserResolver {
return user;
}
- // // Mutation
- // @Mutation(() => Boolean, {
- // description: 'Delete an user account',
- // })
- // @UseGuards(GqlAuthGuard)
- // deleteUser(
- // @GqlUser() user:User
- // ): Promise<boolean> {
- // return pipe(
- // this.userService.deleteUserByUID(user),
- // TE.map(() => true),
- // TE.mapLeft((message) => message.toString()),
- // TE.getOrElse(throwErr)
- // )();
- // }
- //
- // // Subscription
- // @Subscription(() => User, {
- // description: 'Listen for user deletion',
- // resolve: (value) => value,
- // })
- // @UseGuards(GqlAuthGuard)
- // userDeleted(@GqlUser() user: User): AsyncIterator<User> {
- // return this.pubsub.asyncIterator(`user/${user.uid}/deleted`);
- // }
+ @Query(() => User, {
+ description:
+ "Gives details of the user executing this query (pass Authorization 'Bearer' header)",
+ })
+ @UseGuards(GqlAuthGuard)
+ me2(@GqlUser() user: User): User {
+ return user;
+ }
}
diff --git a/packages/hoppscotch-backend/src/utils.ts b/packages/hoppscotch-backend/src/utils.ts
index 061ddeef1..a4756f5e6 100644
--- a/packages/hoppscotch-backend/src/utils.ts
+++ b/packages/hoppscotch-backend/src/utils.ts
@@ -6,8 +6,6 @@ import * as TE from 'fp-ts/TaskEither';
import * as T from 'fp-ts/Task';
import { User } from './user/user.model';
import * as A from 'fp-ts/Array';
-// import { Reflector } from '@nestjs/core';
-// import { TeamMemberRole } from './team/team.model';
/**
* A workaround to throw an exception in an expression.