Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: null value checked on user_settings.properties
Mir Arif Hasan5c032e84be7c
diff --git a/packages/hoppscotch-backend/src/errors.ts b/packages/hoppscotch-backend/src/errors.tsindex e8da11b9c..d5da9ddbe 100644--- a/packages/hoppscotch-backend/src/errors.ts+++ b/packages/hoppscotch-backend/src/errors.ts@@ -227,3 +227,9 @@ export const USER_SETTINGS_UPDATE_FAILED = 'user_settings/update_failed' as cons* (UserSettingsService)*/export const USER_SETTINGS_NOT_FOUND = 'user_settings/not_found' as const;++/**+ * User settings invalid properties+ * (UserSettingsService)+ */+export const USER_SETTINGS_INVALID_PROPERTIES = 'user_settings/invalid_properties' as const;diff --git a/packages/hoppscotch-backend/src/user-settings/user-settings.service.ts b/packages/hoppscotch-backend/src/user-settings/user-settings.service.tsindex ddb870777..700b49857 100644--- a/packages/hoppscotch-backend/src/user-settings/user-settings.service.ts+++ b/packages/hoppscotch-backend/src/user-settings/user-settings.service.ts@@ -6,6 +6,7 @@ import * as E from 'fp-ts/Either';import { stringToJson } from 'src/utils';import { UserSettings } from './user-settings.model';import {+ USER_SETTINGS_INVALID_PROPERTIES,USER_SETTINGS_NOT_FOUND,USER_SETTINGS_UPDATE_FAILED,} from 'src/errors';@@ -38,6 +39,8 @@ export class UserSettingsService {}async createUserSettings(user: User, properties: string) {+ if (!properties) return E.left(USER_SETTINGS_INVALID_PROPERTIES);+const jsonProperties = stringToJson(properties);if (E.isLeft(jsonProperties)) return E.left(jsonProperties.left);@@ -59,6 +62,8 @@ export class UserSettingsService {}async updateUserSettings(user: User, properties: string) {+ if (!properties) return E.left(USER_SETTINGS_INVALID_PROPERTIES);+const jsonProperties = stringToJson(properties);if (E.isLeft(jsonProperties)) return E.left(jsonProperties.left);