Skip to content

Commit

Permalink
Resolving Linting Issues For Scheduler (#1633)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchauhan-aot authored Oct 10, 2024
1 parent 99a3b58 commit 68d4471
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions scheduler/src/modules/cgi-sftp/cgi-sftp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@ import * as Client from 'ssh2-sftp-client';
export class CgiSftpService {
private readonly logger = new Logger(CgiSftpService.name);

upload(fileData: Express.Multer.File, fileName: string) {
async upload(fileData: Express.Multer.File, fileName: string) {
const sftp = new Client();
const connectionInfo: Client.ConnectOptions = getSFTPConnectionInfo();
const remotePath = process.env.CFS_REMOTE_PATH; //Remote CFS Path

sftp
.connect(connectionInfo)
.then(() => {
this.logger.log(`writing file ${remotePath}${fileName}`);
return sftp.put(fileData.buffer, remotePath + fileName);
})
.catch((err) => {
this.logger.error(err);
throw new InternalServerErrorException(err);
})
.finally(() => {
this.logger.log('closing connection');
void sftp.end();
});
try {
await sftp.connect(connectionInfo);
this.logger.log(`Successfully connected to ${process.env.CFS_SFTP_HOST} via SFTP.`);
} catch (error) {
this.logger.error('Cannot connect to sftp.');
this.logger.error(error);
}
try {
const res = await sftp.put(fileData.buffer, remotePath + fileName);
this.logger.log(`Successfully sent file ${fileName} via SFTP.`);
return res;
} catch (error) {
this.logger.error('Failed to send file via SFTP.');
this.logger.error(error);
throw new InternalServerErrorException('Failed to send file via SFTP.');
} finally {
this.logger.log('closing connection');
void sftp.end();
}
}
}
2 changes: 1 addition & 1 deletion scheduler/src/modules/permit/permit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class PermitService {
await lastValueFrom(
this.httpService
.post(url, body, reqConfig)
.pipe(map((response) => response.data)),
.pipe(map((response) => response.data as JSON)),
);
} catch (error) {
this.logger.error(`Error in calling ${url}: ${error}`);
Expand Down

0 comments on commit 68d4471

Please sign in to comment.