Skip to content

Commit

Permalink
refactor: use parameter properties
Browse files Browse the repository at this point in the history
  • Loading branch information
phloose committed Apr 29, 2022
1 parent 28bc7da commit 7461068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
31 changes: 7 additions & 24 deletions src/clamAvService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,15 @@ export interface IScanService {
}

export class ClamAVService implements IScanService {
private useClamd: boolean;

private definitionFiles: string[];

private definitionsDirectory: string;

private freshclamConfig: string;

private clamdConfig: string;

private clamdChildProcess: ChildProcess | null;
private clamdChildProcess: ChildProcess | null = null;

constructor(
useClamd = true,
definitionFiles = DEFINITION_FILES,
definitionsDirectory = DEFINITIONS_DIR,
freshclamConfig = FRESHCLAM_CONFIG,
clamdConfig = CLAMD_CONFIG,
) {
this.useClamd = useClamd;
this.definitionFiles = definitionFiles;
this.definitionsDirectory = definitionsDirectory;
this.freshclamConfig = freshclamConfig;
this.clamdConfig = clamdConfig;
this.clamdChildProcess = null;
}
private useClamd: boolean = true,
private definitionFiles: string[] = DEFINITION_FILES,
private definitionsDirectory: string = DEFINITIONS_DIR,
private freshclamConfig: string = FRESHCLAM_CONFIG,
private clamdConfig: string = CLAMD_CONFIG,
) {}

async scan(filePath: string): Promise<boolean> {
const method = this.useClamd ? this.clamdscan : this.clamscan;
Expand Down
12 changes: 4 additions & 8 deletions src/virusScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ export interface IVirusScan {
}

export class VirusScan implements IVirusScan {
private scanService: IScanService;

private s3: S3;

constructor(scanService: IScanService, s3: S3) {
this.scanService = scanService;
this.s3 = s3;
}
constructor(
private scanService: IScanService,
private s3: S3,
) {}

async scan(key: string, bucket: string): Promise<void> {
const filePath = await this.fetchBucketFile(key, bucket);
Expand Down

0 comments on commit 7461068

Please sign in to comment.