-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PER-9883 [back-end] Delete feature flag endpoint
New endpoint to delete a feature-flag Unit and functional tests are covering all scenarios
- Loading branch information
iuliandanea
committed
Oct 30, 2024
1 parent
5ad4afa
commit 37a60c3
Showing
6 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/api/src/feature_flag/queries/delete_feature_flag.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
DELETE FROM | ||
feature_flag | ||
WHERE | ||
id = :featureFlagId | ||
RETURNING | ||
id AS "featureFlagId"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { logger } from "@stela/logger"; | ||
import createError from "http-errors"; | ||
import { db } from "../../database"; | ||
|
||
export const deleteFeatureFlag = async ( | ||
featureFlagId: string | ||
): Promise<string> => { | ||
const result = await db | ||
.sql("feature_flag.queries.delete_feature_flag", { | ||
featureFlagId, | ||
}) | ||
.catch((err) => { | ||
logger.error(err); | ||
throw new createError.InternalServerError( | ||
"Failed to delete feature flag" | ||
); | ||
}); | ||
|
||
if (result.rows[0] === undefined) { | ||
throw new createError.NotFound("Feature Flag not found"); | ||
} | ||
|
||
return featureFlagId; | ||
}; | ||
|
||
export const deleteFeatureService = { | ||
deleteFeatureFlag, | ||
}; |