message: refactor: applied use of promisify in UploadService
diff: import * as fs from 'fs';
  +import { promisify } from 'util';
  import { Response } from 'express';
  -import { Injectable, NotFoundException, InternalServerErrorException } from '@nestjs/common';
  +import {
  + Injectable,
  + NotFoundException,
  + InternalServerErrorException,
  +} from '@nestjs/common';
  +
  +const fileAccess: (
  + path: string,
  + mode: number | undefined,
  +) => Promise<void> = promisify(fs.access);
  @Injectable()
  export class UploadService {
  - public async sendFile(
  - fileName: string,
  - response: Response,
  - ): Promise<void> {
  + public async sendFile(fileName: string, response: Response): Promise<void> {
  await this.ensureFileExists(fileName);
  await this.sendFileToResponse(fileName, response);
  }
  private async ensureFileExists(fileName: string): Promise<void> {
  try {
  - await this.fileExists(
  - `${__dirname}/../../../upload/${fileName}`,
  - );
  + const path = `${__dirname}/../../../upload/${fileName}`;
  + await fileAccess(path, fs.constants.F_OK);
  } catch (error) {
  throw new NotFoundException(`File '${fileName}' not found`);
  }
  @@ -26,28 +32,14 @@ export class UploadService {
  fileName: string,
  response: Response,
  ): Promise<void> {
  - return new Promise((resolve, reject) => {
  - response.sendfile(
  - fileName,
  - { root: 'upload' },
  - (error: Error) => {
  - if (error) {
  - reject(new InternalServerErrorException(error.message));
  - }
  - resolve();
  - },
  + // eslint-disable-next-line @typescript-eslint/no-explicit-any
  + const sendFile: (path: string, options: any) => Promise<void> = promisify(
  + response.sendfile.bind(response),
  );
  - });
  - }
  - private fileExists(path: string): Promise<void> {
  - return new Promise((resolve, reject) => {
  - fs.access(path, fs.constants.F_OK, (error) => {
  - if (error) {
  - reject(error);
  - return;
  + try {
  + await sendFile(fileName, { root: 'upload' });
  + } catch (error) {
  + throw new InternalServerErrorException(error.message);
  }
  - resolve();
  - });
  - });
  }
  }
  