This commit is contained in:
Daniel Hougaard
2024-10-04 18:43:29 +04:00
parent 3b74c232dc
commit 0814245ce6
3 changed files with 61 additions and 17 deletions
@@ -215,29 +215,26 @@ export const projectEnvServiceFactory = ({
}
};
const getEnvironmentById = async ({ projectId, actor, actorId, actorOrgId, actorAuthMethod, id }: TGetEnvDTO) => {
const getEnvironmentById = async ({ actor, actorId, actorOrgId, actorAuthMethod, id }: TGetEnvDTO) => {
const environment = await projectEnvDAL.findById(id);
if (!environment) {
throw new NotFoundError({
message: "Environment does not exist"
});
}
const { permission } = await permissionService.getProjectPermission(
actor,
actorId,
projectId,
environment.projectId,
actorAuthMethod,
actorOrgId
);
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Read, ProjectPermissionSub.Environments);
const [env] = await projectEnvDAL.find({
id,
projectId
});
if (!env) {
throw new NotFoundError({
message: "Environment does not exist"
});
}
return env;
return environment;
};
return {
@@ -23,4 +23,4 @@ export type TReorderEnvDTO = {
export type TGetEnvDTO = {
id: string;
} & TProjectPermission;
} & Omit<TProjectPermission, "projectId">;