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

This commit is contained in:
Balu Babu
2022-12-08 22:19:14 +05:30
parent bfc5bfe973
commit c5466edf71
11 changed files with 15 additions and 111 deletions

View File

@@ -2,7 +2,7 @@ module.exports = {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {
project: 'tsconfig.json', project: 'tsconfig.json',
tsconfigRootDir : __dirname, tsconfigRootDir: __dirname,
sourceType: 'module', sourceType: 'module',
}, },
plugins: ['@typescript-eslint/eslint-plugin'], plugins: ['@typescript-eslint/eslint-plugin'],

View File

@@ -1,4 +1,4 @@
{ {
"singleQuote": true, "singleQuote": true,
"trailingComma": "all" "trailingComma": "all"
} }

View File

@@ -5,16 +5,11 @@ WORKDIR /usr/src/app
# # Install pnpm # # Install pnpm
RUN npm i -g pnpm RUN npm i -g pnpm
# # NPM package install
# COPY package*.json ./
# RUN pnpm install
# Prisma bits # Prisma bits
COPY prisma ./ COPY prisma ./
RUN pnpx prisma generate RUN pnpx prisma generate
# # NPM package install
COPY . . COPY . .
RUN pnpm i RUN pnpm i
@@ -25,6 +20,4 @@ ENV APP_PORT=${PORT}
ENV DB_URL=${DATABASE_URL} ENV DB_URL=${DATABASE_URL}
ENV PRODUCTION=true ENV PRODUCTION=true
#ENV FB_SERVICE_KEY_PATH="secrets/fb-service-key.json"
# CMD ["pnpm", "run", "start:dev"]
CMD ["pnpm", "run", "start"] CMD ["pnpm", "run", "start"]

View File

@@ -6,8 +6,9 @@ services:
- PRODUCTION=false - PRODUCTION=false
- DATABASE_URL=postgresql://postgres:testpass@dev-db:5432/hoppscotch?connect_timeout=300 - DATABASE_URL=postgresql://postgres:testpass@dev-db:5432/hoppscotch?connect_timeout=300
- PORT=3000 - PORT=3000
# volumes: volumes:
# - .:/usr/src/app - .:/usr/src/app
- /usr/src/app/node_modules/
depends_on: depends_on:
- dev-db - dev-db
ports: ports:

View File

@@ -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!');
});
});
});

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -1,8 +0,0 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@@ -24,13 +24,6 @@ async function bootstrap() {
} else { } else {
console.log('Enabling CORS with production settings'); 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({ app.enableCors({
origin: true, origin: true,
}); });

View File

@@ -6,20 +6,10 @@ import { GqlUser } from '../decorators/gql-user.decorator';
@Resolver(() => User) @Resolver(() => User)
export class UserResolver { 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 // eslint-disable-next-line @typescript-eslint/no-empty-function
constructor() {} 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, { @Query(() => User, {
description: description:
"Gives details of the user executing this query (pass Authorization 'Bearer' header)", "Gives details of the user executing this query (pass Authorization 'Bearer' header)",
@@ -29,29 +19,12 @@ export class UserResolver {
return user; return user;
} }
// // Mutation @Query(() => User, {
// @Mutation(() => Boolean, { description:
// description: 'Delete an user account', "Gives details of the user executing this query (pass Authorization 'Bearer' header)",
// }) })
// @UseGuards(GqlAuthGuard) @UseGuards(GqlAuthGuard)
// deleteUser( me2(@GqlUser() user: User): User {
// @GqlUser() user:User return 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`);
// }
} }

View File

@@ -6,8 +6,6 @@ import * as TE from 'fp-ts/TaskEither';
import * as T from 'fp-ts/Task'; import * as T from 'fp-ts/Task';
import { User } from './user/user.model'; import { User } from './user/user.model';
import * as A from 'fp-ts/Array'; 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. * A workaround to throw an exception in an expression.