misc: created abstraction for get kms by id

This commit is contained in:
Sheen Capadngan
2024-07-30 23:03:55 +05:30
committed by =
parent ffc1b1ec1c
commit 64869ea8e0
3 changed files with 18 additions and 15 deletions
+14 -1
View File
@@ -666,6 +666,18 @@ export const kmsServiceFactory = ({
};
};
const getKmsById = async (kmsKeyId: string, tx?: Knex) => {
const kms = await kmsDAL.findByIdWithAssociatedKms(kmsKeyId, tx);
if (!kms.id) {
throw new NotFoundError({
message: "KMS not found"
});
}
return kms;
};
const startService = async () => {
const appCfg = getConfig();
// This will switch to a seal process and HMS flow in future
@@ -725,6 +737,7 @@ export const kmsServiceFactory = ({
getProjectSecretManagerKmsKey,
updateProjectSecretManagerKmsKey,
getProjectKeyBackup,
loadProjectKeyBackup
loadProjectKeyBackup,
getKmsById
};
};