Skip to content

Commit

Permalink
Merge pull request #150 from chingu-x/refactor/add_response_code_to_f…
Browse files Browse the repository at this point in the history
…eature_delete

Introduce DeleteFeatureResponse and update deleteFeature method with a status code and a message
  • Loading branch information
timDeHof committed May 10, 2024
2 parents 709a6aa + 40698c9 commit 7bdaacc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
FeatureCategoriesResponse,
ExtendedFeaturesResponse,
FeatureResponse,
DeleteFeatureResponse,
} from "./features.response";
import { CustomRequest } from "../global/types/CustomRequest";

Expand Down Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions src/features/features.response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions src/features/features.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ export class FeaturesService {
throw new NotFoundException(
`FeatureId (id: ${featureId}) does not exist.`,
);
} else {
return {
message: "Feature deleted successfully",
status: 200,
};
}
}

Expand Down

0 comments on commit 7bdaacc

Please sign in to comment.