diff --git a/packages/hoppscotch-backend/src/errors.ts b/packages/hoppscotch-backend/src/errors.ts index 3314acf59..2a98aef38 100644 --- a/packages/hoppscotch-backend/src/errors.ts +++ b/packages/hoppscotch-backend/src/errors.ts @@ -318,18 +318,6 @@ export const TEAM_INVITATION_NOT_FOUND = */ export const SHORTCODE_NOT_FOUND = 'shortcode/not_found' as const; -/** - * Invalid ShortCode format - * (ShortcodeService) - */ -export const SHORTCODE_INVALID_JSON = 'shortcode/invalid_json' as const; - -/** - * ShortCode already exists in DB - * (ShortcodeService) - */ -export const SHORTCODE_ALREADY_EXISTS = 'shortcode/already_exists' as const; - /** * Invalid or non-existent TEAM ENVIRONMENT ID * (TeamEnvironmentsService) diff --git a/packages/hoppscotch-backend/src/shortcode/shortcode.resolver.ts b/packages/hoppscotch-backend/src/shortcode/shortcode.resolver.ts index 60128087b..6ecafba6f 100644 --- a/packages/hoppscotch-backend/src/shortcode/shortcode.resolver.ts +++ b/packages/hoppscotch-backend/src/shortcode/shortcode.resolver.ts @@ -1,6 +1,5 @@ import { Args, - Context, ID, Mutation, Query, diff --git a/packages/hoppscotch-backend/src/shortcode/shortcode.service.spec.ts b/packages/hoppscotch-backend/src/shortcode/shortcode.service.spec.ts index 862cdf0d1..c84ddef7b 100644 --- a/packages/hoppscotch-backend/src/shortcode/shortcode.service.spec.ts +++ b/packages/hoppscotch-backend/src/shortcode/shortcode.service.spec.ts @@ -1,8 +1,6 @@ import { mockDeep, mockReset } from 'jest-mock-extended'; import { PrismaService } from '../prisma/prisma.service'; import { - SHORTCODE_ALREADY_EXISTS, - SHORTCODE_INVALID_JSON, SHORTCODE_INVALID_PROPERTIES_JSON, SHORTCODE_INVALID_REQUEST_JSON, SHORTCODE_NOT_FOUND, diff --git a/packages/hoppscotch-backend/src/shortcode/shortcode.service.ts b/packages/hoppscotch-backend/src/shortcode/shortcode.service.ts index c058fa271..8c41a185c 100644 --- a/packages/hoppscotch-backend/src/shortcode/shortcode.service.ts +++ b/packages/hoppscotch-backend/src/shortcode/shortcode.service.ts @@ -1,6 +1,5 @@ import { Injectable, OnModuleInit } from '@nestjs/common'; import * as T from 'fp-ts/Task'; -import * as O from 'fp-ts/Option'; import * as TO from 'fp-ts/TaskOption'; import * as E from 'fp-ts/Either'; import { PrismaService } from 'src/prisma/prisma.service'; @@ -123,7 +122,8 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit { userInfo: AuthUser, ) { const requestData = stringToJson(request); - if (E.isLeft(requestData)) return E.left(SHORTCODE_INVALID_REQUEST_JSON); + if (E.isLeft(requestData) || !requestData.right) + return E.left(SHORTCODE_INVALID_REQUEST_JSON); const parsedProperties = stringToJson(properties); if (E.isLeft(parsedProperties))