Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagarjun Sanji committed Sep 27, 2024
1 parent 439744b commit c439fa3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
32 changes: 31 additions & 1 deletion src/helpers/debrickedServiceHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiHelper } from "./apiHelper";
import { Repository, RequestParam } from "../types/index";
import { DependencyResponse, DependencyVulnerabilityWrapper, Repository, RequestParam } from "../types/index";
import { Logger } from "./loggerHelper";
import { SecondService } from "../constants";
import { SentryHelper } from "./sentryHelper";
Expand Down Expand Up @@ -31,4 +31,34 @@ export class DebrickedServiceHelper {
throw error;
}
}

/**
* Fetches Dependencies Hierarchy.
*
* @returns {Promise<DependencyResponse>} A promise resolving to Dependencies Hierarchy.
*/
public async fetchDependenciesHierarchy(requestParam: RequestParam): Promise<DependencyResponse> {
this.logger.logInfo("Fetching Dependencies Hierarchy");
try {
return await this.apiHelper.get(requestParam);
} catch (error: any) {
SentryHelper.captureException(error);
throw error;
}
}

/**
* Fetches Vulnerabilities.
*
* @returns {Promise<DependencyVulnerabilityWrapper>} A promise resolving to Vulnerabilities.
*/
public async fetchVulnerabilities(requestParam: RequestParam): Promise<DependencyVulnerabilityWrapper> {
this.logger.logInfo("Fetching Vulnerabilities");
try {
return await this.apiHelper.get(requestParam);
} catch (error: any) {
SentryHelper.captureException(error);
throw error;
}
}
}
8 changes: 5 additions & 3 deletions src/services/dependencyService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { apiHelper, globalStore, Logger } from "../helpers";
import { debrickedServiceHelper, globalStore, Logger } from "../helpers";
import { Package, RequestParam } from "../types";
import {
DependencyVulnerability,
Expand All @@ -17,7 +17,8 @@ export class DependencyService {
repoId: repoID,
commitId: commitId,
};
const response: DependencyResponse = await apiHelper.get(requestParam);

const response: DependencyResponse = await debrickedServiceHelper.fetchDependenciesHierarchy(requestParam);
const packageData = globalStore.getPackages();

response.dependencies.forEach((dependency: Dependency) => {
Expand Down Expand Up @@ -66,7 +67,8 @@ export class DependencyService {
repoId: repoId,
commitId: commitId,
};
const response: DependencyVulnerabilityWrapper = await apiHelper.get(requestParam);
const response: DependencyVulnerabilityWrapper =
await await debrickedServiceHelper.fetchVulnerabilities(requestParam);
const vulnerabilityMap = new Map<string, DependencyVulnerability[]>();

response.vulnerabilities.forEach((vul: DependencyVulnerability) => {
Expand Down

0 comments on commit c439fa3

Please sign in to comment.