-
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.
Merge pull request #140 from PermanentOrg/PER-9883
PER-9883 [back-end] Delete feature flag endpoint
- Loading branch information
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, | ||
}; |