diff --git a/src/controllers/summary.controller.js b/src/controllers/summary.controller.js index 0bcf0f4..926ee8d 100644 --- a/src/controllers/summary.controller.js +++ b/src/controllers/summary.controller.js @@ -3,6 +3,9 @@ import { getSummary, getTitle } from '../services/chatGPT.service.js'; import { readFileFromObjectStorage } from '../services/storage.service.js'; import { getScriptFileName } from '../services/storage.service.js'; import { chatGPTCall } from '../services/chatGPT.service.js'; +import { BaseError } from "../../config/error.js"; +import { response } from "../../config/response.js"; +import { status } from "../../config/response.status.js"; import axios from 'axios'; @@ -80,11 +83,11 @@ export const summary = async (req, res) => { "summary":summaryData.Summary, "tag":tagData } - - res.status(200).json({ + res.send(response(status.SUCCESS,{ message: 'File processed successfully using existing data', finalData - }); + })); + } else { // 스크립트 파일이 없으면 오류 호출 diff --git a/src/controllers/translateMP3.controller.js b/src/controllers/translateMP3.controller.js index 6622569..6d31687 100644 --- a/src/controllers/translateMP3.controller.js +++ b/src/controllers/translateMP3.controller.js @@ -2,7 +2,9 @@ import { convertVideoToAudio } from '../services/translateToMP3.service.js'; import { checkFileExistsInStorage } from '../services/storage.service.js'; import { uploadFileToStorage } from '../services/storage.service.js'; - +import { BaseError } from "../../config/error.js"; +import { response } from "../../config/response.js"; +import { status } from "../../config/response.status.js"; export const convertMP3 = async (req, res) => { try{ @@ -21,16 +23,25 @@ export const convertMP3 = async (req, res) => { if (!mp3Exists) { const audioFilePath = await convertVideoToAudio(videoId); // MP3 파일 변환 await uploadFileToStorage(audioFilePath); // 파일 업로드 후 로컬파일 삭제 - return res.status(200).json({ status: 200, success: true, message: 'MP3 변환 완료',progress: '25' ,nextEndPoint: '/video/speech', videoId: videoId }); + + res.send(response(status.SUCCESS,{ + message: 'MP3 변환 완료',progress: '25' ,nextEndPoint: '/video/speech', videoId: videoId + })); + } else{ - - return res.status(200).json({ status: 200, success: true, message: 'MP3가 이미 존재합니다!',progress: '25' ,nextEndPoint: '/video/summary', videoId: videoId}); + res.send(response(status.SUCCESS,{ + message: 'MP3가 이미 존재합니다!',progress: '25' ,nextEndPoint: '/video/summary', videoId: videoId} + )); + } }catch (error) { - res.status(500).json({ message: 'Error in converting to MP3', error: error.toString() }); + res.send(response(status.BAD_REQUEST({ + message: 'Error in converting to MP3', error: error.toString() + }))) + console.log(error); } } diff --git a/src/services/video.service.js b/src/services/video.service.js index 7dfd6cc..2f5fdad 100644 --- a/src/services/video.service.js +++ b/src/services/video.service.js @@ -63,7 +63,8 @@ export const viewSimpleVideo=async(data)=>{ } catch (error) { console.error(error); - return {"videos":[]} + throw new BaseError(status.VIDEO_NOT_FOUND); + // return {"videos":[]} } } @@ -83,7 +84,7 @@ export const viewRecentVideo=async(data)=>{ console.log("비디오 정보: ",getVideoData); return getSimpleVideoResponseDTO(getVideoData,TagData); } catch (error) { - return {"video":[]} + throw new BaseError(status.VIDEO_NOT_FOUND); } }