Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Linting Issues For Scheduler #1633

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading