From 106f4f8b98e09e0fe99bf3a8c999a0b21c721d92 Mon Sep 17 00:00:00 2001 From: timDeHof Date: Wed, 8 May 2024 20:16:37 -0400 Subject: [PATCH 1/2] feat(features): add DeleteFeatureResponse class to handle response for feature deletion fix(features): update deleteFeature method in FeaturesService to return a proper response object The DeleteFeatureResponse class is added to handle the response for feature deletion. It includes a message and statusCode property. The deleteFeature method in FeaturesService is updated to return a response object with a success message and status code of 200 when a feature is successfully deleted. This improves the consistency and clarity of the code when handling feature deletion. --- src/features/features.controller.ts | 2 ++ src/features/features.response.ts | 8 ++++++++ src/features/features.service.ts | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/features/features.controller.ts b/src/features/features.controller.ts index 50f907ea..8043475b 100644 --- a/src/features/features.controller.ts +++ b/src/features/features.controller.ts @@ -33,6 +33,7 @@ import { FeatureCategoriesResponse, ExtendedFeaturesResponse, FeatureResponse, + DeleteFeatureResponse, } from "./features.response"; import { CustomRequest } from "../global/types/CustomRequest"; @@ -256,6 +257,7 @@ export class FeaturesController { @ApiResponse({ status: HttpStatus.OK, description: "Successfully deleted feature.", + type: DeleteFeatureResponse, }) //Can only delete if loggedIn userId mataches addedBy userId @Delete("/features/:featureId") diff --git a/src/features/features.response.ts b/src/features/features.response.ts index 93d5cc69..eec4fd78 100644 --- a/src/features/features.response.ts +++ b/src/features/features.response.ts @@ -95,3 +95,11 @@ export class ExtendedFeaturesResponse { @ApiProperty() addedBy: AddedBY; } + +export class DeleteFeatureResponse { + @ApiProperty({ example: "The feature was deleted successfully" }) + message: string; + + @ApiProperty({ example: 200 }) + statusCode: number; +} diff --git a/src/features/features.service.ts b/src/features/features.service.ts index 1a0deaa0..220f5f35 100644 --- a/src/features/features.service.ts +++ b/src/features/features.service.ts @@ -369,6 +369,11 @@ export class FeaturesService { throw new NotFoundException( `FeatureId (id: ${featureId}) does not exist.`, ); + } else { + return { + message: "Feature deleted successfully", + status: 200, + }; } } From 40698c9d07ab8ac5a45fcd9306a6ff84b5bdac0a Mon Sep 17 00:00:00 2001 From: timDeHof Date: Wed, 8 May 2024 20:42:46 -0400 Subject: [PATCH 2/2] chore(CHANGELOG.md): update changelog with new feature and fix The changelog has been updated to include the following changes: - A new feature has been added to the deleteFeature method. It now uses a DeleteFeatureResponse and returns an object with a successful status and a message. This change was made in pull request #150. - Various updates and additions have been made to the test github actions workflow, form title references, and form input types. These changes were made in pull requests #143, #145, and #146 respectively. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88a94ffe..48b94ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Another example [here](https://co-pilot.dev/changelog) - Update test github actions workflow with timeout [#143](https://github.com/chingu-x/chingu-dashboard-be/pull/143) - Refractor of all form title reference to use values from formTitle.ts [#145](https://github.com/chingu-x/chingu-dashboard-be/pull/145) - Update/Add more form input types [#146](https://github.com/chingu-x/chingu-dashboard-be/pull/146) +- Update the deleteFeature method to use a DeleteFeatureResponse and return an object with a successful status and a message [#150](https://github.com/chingu-x/chingu-dashboard-be/pull/150) ### Fixed