Skip to content

Commit

Permalink
[FIX] TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
JiHyeonSu committed Feb 16, 2024
1 parent 5de403c commit 4f2a170
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cors from 'cors';
import jwt from 'jsonwebtoken';
import cookieParser from 'cookie-parser';

import { v4 as uuidv4 } from 'uuid';
import { response } from './config/response.js';
import { BaseError } from './config/error.js';
import { status } from './config/response.status.js';
Expand Down Expand Up @@ -96,10 +97,8 @@ app.listen(app.get('port'), () => {
// 임시 토큰 생성 및 쿠키 저장 미들웨어
function generateTempToken(req, res, next) {
// 임시 토큰 생성 (여기서는 간단히 예시를 위한 토큰을 생성합니다)
const tempToken = jwt.sign({ user: 'tempUser' }, process.env.JWT_SECRET);

// 쿠키에 토큰 저장
res.cookie('tempToken', tempToken, { httpOnly: true });
const uniqueId = uuidv4(); // 'uuid' 모듈의 v4 함수를 사용하여 UUID 생성
const tempToken = jwt.sign({ userId: uniqueId }, process.env.JWT_SECRET);

// 토큰 정보를 JSON 형태로 응답
res.status(200).json({ status: 200, success: true, message: '임시토큰이 발행되었습니다.', result: { tempToken }});
Expand Down
19 changes: 16 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"swagger-cli": "^4.0.4",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"uuid": "^9.0.1",
"youtube-mp3-downloader": "^0.7.11",
"ytdl-core": "^4.11.5"
},
Expand Down
5 changes: 3 additions & 2 deletions src/controllers/summary.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ export const processVideo = async (req, res) => {
if(!token) {
return res.status(401).send("비정상 접근입니다.");
}

const id =videoId;
console.log("id",id);
let videoTitle="";

getYoutubeTitle(videoId,async function(err,title){
videoTitle=title;
})
const clientId = req.query.clientId;

const clientId = token;

// Object Storage에서 해당 MP3 파일이 존재하는지 확인
const mp3Exists = await checkFileExistsInStorage(process.env.OBJECT_STORAGE_BUCKET_NAME, `${videoId}.mp3`);
Expand Down
3 changes: 2 additions & 1 deletion src/routes/progress.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import express from 'express';
import { addClient, sendProgress } from '../services/progress.service.js';
import { v4 as uuidv4 } from 'uuid';

const progressRoute = express.Router();

router.get('/progress-stream', (req, res) => {
const clientId = req.query.clientId || new Date().toISOString();
const clientId = req.query.clientId || uuidv4();

res.setHeader('Content-Type', 'text/event-stream');
res.setHeader('Cache-Control', 'no-cache');
Expand Down

0 comments on commit 4f2a170

Please sign in to comment.