Skip to content

Commit

Permalink
[fix] 여러가지 응답 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jainefer committed Feb 17, 2024
1 parent 0df05b9 commit 73a18a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/controllers/summary.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';


Expand Down Expand Up @@ -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 {
// 스크립트 파일이 없으면 오류 호출
Expand Down
21 changes: 16 additions & 5 deletions src/controllers/translateMP3.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/services/video.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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":[]}
}

}
Expand All @@ -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);
}

}
Expand Down

0 comments on commit 73a18a9

Please sign in to comment.