Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ export const certificatePolicyDALFactory = (db: TDbClient) => {
.del()
.returning("*")) as Record<string, unknown>[];

return certificatePolicy;
if (!certificatePolicy) {
return null;
}

return parseJsonFields(certificatePolicy);
} catch (error) {
throw new DatabaseError({ error, name: "Delete certificate policy" });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ export const certificatePolicyServiceFactory = ({
throw new NotFoundError({ message: "Failed to delete certificate policy" });
}

return deletedTemplate as TCertificatePolicy;
return deletedTemplate;
};

const validateCertificateRequest = async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,19 @@ export const certificateProfileDALFactory = (db: TDbClient) => {
}
};

const deleteById = async (id: string, tx?: Knex): Promise<TCertificateProfile> => {
const deleteById = async (id: string, tx?: Knex): Promise<TCertificateProfile | undefined> => {
try {
const [certificateProfile] = (await (tx || db)(TableName.PkiCertificateProfile)
.where({ id })
.del()
.returning("*")) as [TCertificateProfile];
return certificateProfile;
const [certificateProfile] = await (tx || db)(TableName.PkiCertificateProfile).where({ id }).del().returning("*");

if (!certificateProfile) return undefined;

return {
...certificateProfile,
externalConfigs: certificateProfile.externalConfigs
? (JSON.parse(certificateProfile.externalConfigs) as Record<string, unknown>)
: null,
defaults: (certificateProfile.defaults as TCertificateProfileDefaults) ?? null
} as TCertificateProfile;
} catch (error) {
throw new DatabaseError({ error, name: "Delete certificate profile" });
}
Expand Down
Loading