From 9746421942c150b512b63e4a65dd47e7836ab7ff Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Thu, 22 May 2025 09:22:24 +0000 Subject: [PATCH 01/48] =?UTF-8?q?[fix]=20=ED=95=99=EA=B5=90=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 +- src/controllers/home.ctrl.js | 45 +++++++++++- src/models/University.js | 2 +- src/models/UniversityStorage.js | 2 +- src/public/js/council.js | 9 ++- src/rabbit/rabbitmq.js | 118 ++++++++++++++++---------------- src/routes/startRoute.js | 1 + 7 files changed, 115 insertions(+), 66 deletions(-) diff --git a/main.js b/main.js index 37a2200..a9d17e0 100644 --- a/main.js +++ b/main.js @@ -6,6 +6,7 @@ const bodyParser = require("body-parser"); const path = require('path'); const db = require('./src/config/db.js'); const app = express(); +const rabbitmq = require("./src/rabbit/rabbitmq.js") //에러 라우팅 const errorController = require("./src/controllers/errorControllers.js"); @@ -45,7 +46,8 @@ app.use(errorController.respondInternalEroor); //app.post("/send_msg", mq.send_message); //app.get("/get_msg", mq.recv_message); -// const port = process.env.PORT; +//const port = process.env.PORT; +console.log("process.env.PORT: ", process.env.PORT); const port = 3001; app.listen(port, ()=> { console.log('running') diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 7703c35..a7ffb95 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -1,6 +1,7 @@ "use strict" const University = require("../models/University"); +const { sendUniversityURL, receiveUniversityData } = require('../rabbit/rabbitmq'); //const Partner = require("../models/Partner"); // const User = require("../models/User"); // const Council = require("../models/Council"); @@ -26,7 +27,23 @@ const mainpage = { const university = new University(); const response = await university.showUniversityNameList(); return res.json(response); - } + }, + + + getUniversityName: async (req, res) => { + console.log("home.ctrl의 getUniversityName "); + console.log("req.body:", req.body); + + if (!req.body || !req.body.university_url) { + console.error("❌ university_url이 전달되지 않았습니다."); + return res.status(400).json({ error: "university_url이 필요합니다." }); + } + + const university = new University(); + const response = await university.getUniversityName(req.body.university_url); + console.log(response); + return res.json(response); + }, } //council 페이지 @@ -34,9 +51,33 @@ const council = { getUniversityName: async (req, res) => { console.log("home.ctrl의 getUniversityName "); const university = new University(); - const response = await university.getUniversityName(req.body.university_url); + + if (!req.body || !req.body.university_url) { + console.error("❌ university_url이 전달되지 않았습니다."); + return res.status(400).json({ error: "university_url이 필요합니다." }); + } + + const response = await university.getUnversityUrlToName(req.body.university_url); console.log(response); return res.json(response); + }, + + getUniversityLocation: async (req, res) => { + console.log("home.ctrl의 getUniversityLocation"); + console.log("req.body:", req.body); + try { + const university_url = req.body.university_url; + + // RabbitMQ로 university_location 요청 및 수신 + await sendUniversityURL(university_url, 'SendUniversityLocation'); + const university_location = await receiveUniversityData('RecvUniversityLocation'); + + return res.json(university_location); + + } catch (err) { + console.error('getUniversityLocation error:', err); + return res.status(500).json({ error: 'Internal Server Error' }); + } } } diff --git a/src/models/University.js b/src/models/University.js index 1d5f8e3..396f78a 100644 --- a/src/models/University.js +++ b/src/models/University.js @@ -18,7 +18,7 @@ class University{ async getUnversityUrlToName(university_url){ console.log("University.js의 getUnversityUrlToName\n"); try{ - const response=await UniversityStorage.getUnversityUrlToName(university_id); + const response=await UniversityStorage.getUnversityUrlToName(university_url); return response; }catch(err){ return{success:false,msg:err}; diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 11da25f..438342e 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -33,7 +33,7 @@ class UniversityStorage { reject(err) } const query = "SELECT university_name FROM University WHERE university_url =?;"; - pool.query(query, [university_id], (err, data) => { + pool.query(query, [university_url], (err, data) => { connection.release(); if (err) reject(`${err}`); diff --git a/src/public/js/council.js b/src/public/js/council.js index c22caf4..9ecd3aa 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -1,5 +1,5 @@ -//import loadKakaoMap from '/js/kakaomapLoader.js'; -//import apiKeys from './apiKey.js'; +import loadKakaoMap from '/js/kakaomapLoader.js'; +import apiKeys from './apiKey.js'; console.log("council.js 시작1"); //테스트용 로그 @@ -218,7 +218,9 @@ function councilLoad() { const req = { university_url: universityUrl }; + console.log("req:", req);//테스트용 로그 + console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 fetch(`${apiUrl}/getUniversityName`, { method: "POST", headers: { @@ -228,9 +230,10 @@ function councilLoad() { }) .then((res) => res.json()) .then(res => { - console.log("universityName: ", res.universityName); //테스트용 로그 Uniname.push(res.university_name); universityName.innerHTML = Uniname[0]; + console.log("council의 Uniname[0]: ", Uniname[0]); //테스트용 로그 + console.log("council의 universityName: ", universityName.innerHTML); //테스트용 로그 }); // .then(() => { // return fetch(`${apiUrl}/getCardNewsImageUrl`, { diff --git a/src/rabbit/rabbitmq.js b/src/rabbit/rabbitmq.js index d8eea0d..2a2298f 100644 --- a/src/rabbit/rabbitmq.js +++ b/src/rabbit/rabbitmq.js @@ -1,74 +1,76 @@ const amqp = require("amqplib"); -class RabbitmqWrapper { - constructor(url, queueName, options) { - // 객체 초기화 - this._url = url; - this._queueName = queueName; - this._options = options || {}; +const RECV_QUEUES = [ + 'RecvUniversityName', + 'RecvUniversityLocation' +] - // public - this.channel = undefined; - this.queue = undefined; - } +const SEND_QUEUES = [ + 'SendUniversityName', + 'SendUniversityLocation' +] - // 커넥트 생성하고 채널 연결 - async setup() { - const connect = await amqp.connect(this._url); //mysqlconnect - const channel = await connect.createChannel(); //mysql-database - this.channel = channel; - } +let channel; + +async function connectRabbitMQ() { + console.log("Rabbit: ", process.env.RABBIT); + const rabbitUrl = process.env.RABBIT || 'amqp://localhost'; // env 변수 사용, 없으면 localhost 기본 + const connection = await amqp.connect(rabbitUrl); + channel = await connection.createChannel(); - // 채널에다가 queue 만들어주기 queue는 메세지를 수신 받을 수 있는 이름 - async assertQueue() { - const queue = await this.channel.assertQueue(this._queueName, { - durable: false, // false는 볼 때까지 보관, true는 일정시간이 지나면 사라짐 - }); - this.queue = queue; + // 모든 RECV 큐 선언 + for (const queue of RECV_QUEUES) { + await channel.assertQueue(queue, { durable: false }); } - // queue에 데이터보내기 - async sendToQueue(msg) { - const sending = await this.channel.sendToQueue( - this._queueName, - this.encode(msg), - { - persistent: true, - } - ); - return sending; + return channel; +} + +// university_url을 전송 +async function sendUniversityURL(university_url, sendQueueName) { + if (!channel) await connectRabbitMQ(); + let recvQueueName; + if(sendQueueName == 'SendUniversityName'){ + recvQueueName = 'RecvUniversityName'; + } else if(sendQueueName == 'SendUniversityLocation'){ + recvQueueName = 'RecvUniversityLocation' + } else { + console.log("명시되지 않은 sendQueueName 입니다."); } - // queue에 있는 데이터 가져오기 - async recvFromQueue() { - const message = await this.channel.get(this._queueName, {}); - if (message) { - this.channel.ack(message); - console.log(message.content); - console.log(message.content.toString()) - return message.content.toString(); - } else { - return null; + channel.sendToQueue( + sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 + Buffer.from(JSON.stringify({ university_url })), + { + replyTo: recvQueueName, } - } + ); + console.log(`[start-service] university_url 전송: ${university_url} → ${sendQueueName}`); +} - // 문자를 Buffer로 바꿈 - encode(doc) { - return Buffer.from(JSON.stringify(doc)); - } +// university data 수신 +async function receiveUniversityData(queueName) { + if (!channel) await connectRabbitMQ(); - // 메세지보내기 - async send_message(msg) { - await this.setup(); //레빗엠큐 연결 - await this.assertQueue(); //큐생성 - await this.sendToQueue(msg); //생성큐메세지전달 + if (!RECV_QUEUES.includes(queueName)) { + throw new Error(`알 수 없는 수신 큐: ${queueName}`); } - // 메세지 가져오기 - async recv_message() { - await this.setup(); - return await this.recvFromQueue(); - } + return new Promise((resolve, reject) => { + channel.consume(queueName, (msg) => { + if (msg) { + const data = JSON.parse(msg.content.toString()); + console.log(`[start-service] ${queueName} 수신:`, data); + channel.ack(msg); // 메시지 확인(ack)해서 큐에서 제거 + resolve(data); + } else { + reject(new Error('메시지를 받지 못했습니다.')); + } + }, { noAck: false }); // noAck: false 로 ack를 직접 호출하게 함 + }); } -module.exports = RabbitmqWrapper; \ No newline at end of file +module.exports = { + sendUniversityURL, + receiveUniversityData +}; diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 61aa0b5..841ec68 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -10,6 +10,7 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); //council 페이지 router.get("/council/:university_url", ctrl.output.council); router.post("/getUniversityName", ctrl.council.getUniversityName); +router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); // council 라우터 // router.get("/council/:universityname",ctrl.result.council); From d0f048474b240182f87c7575dfe809dac63a2ccf Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Fri, 23 May 2025 06:30:59 +0000 Subject: [PATCH 02/48] =?UTF-8?q?[FEAT]=20=ED=81=B4=EB=9D=BC=EC=9A=B0?= =?UTF-8?q?=EB=93=9C=EC=8A=A4=ED=86=A0=EB=A6=AC=EC=A7=80=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/UniversityStorage.js | 2 ++ src/utils/gcsUploader.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/utils/gcsUploader.js diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 438342e..29b163d 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -1,6 +1,8 @@ "use strict" const { pool } = require("../config/db"); +const { uploadImageToGCS } = require("../utils/gcsUploader"); + class UniversityStorage { //모든 대학 정보 가져오기 static getUniversityName() { diff --git a/src/utils/gcsUploader.js b/src/utils/gcsUploader.js new file mode 100644 index 0000000..b46ff9d --- /dev/null +++ b/src/utils/gcsUploader.js @@ -0,0 +1,28 @@ +// src/utils/gcsUploader.js +const { Storage } = require('@google-cloud/storage'); +const path = require('path'); +const uuid = require('uuid'); +require('dotenv').config(); + +const storage = new Storage({ + keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS, +}); +const bucket = storage.bucket('uniunity_bucket'); + +async function uploadImageToGCS(fileBuffer, originalName) { + const fileName = `${uuid.v4()}_${originalName}`; + const file = bucket.file(fileName); + + await file.save(fileBuffer, { + resumable: false, + contentType: 'image/jpeg', + public: true, + metadata: { + cacheControl: 'public, max-age=31536000', + }, + }); + + return `https://storage.googleapis.com/${bucket.name}/${fileName}`; +} + +module.exports = { uploadImageToGCS }; From 368a4fa266b4ee2e6f61d28fba83efb28b61df3d Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Fri, 23 May 2025 17:12:51 +0900 Subject: [PATCH 03/48] =?UTF-8?q?[FEAT]=20getImages=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 +-- src/controllers/home.ctrl.js | 15 +++++++++ src/models/University.js | 7 +++- src/models/UniversityStorage.js | 58 +++++++++++++++++++++++++++++++++ src/public/js/council.js | 22 +++++++++++++ src/rabbit/rabbitmq.js | 51 +++++++++++++++-------------- src/routes/startRoute.js | 2 ++ 7 files changed, 130 insertions(+), 29 deletions(-) diff --git a/main.js b/main.js index a9d17e0..00fb77d 100644 --- a/main.js +++ b/main.js @@ -46,9 +46,7 @@ app.use(errorController.respondInternalEroor); //app.post("/send_msg", mq.send_message); //app.get("/get_msg", mq.recv_message); -//const port = process.env.PORT; -console.log("process.env.PORT: ", process.env.PORT); -const port = 3001; +const port = process.env.PORT; app.listen(port, ()=> { console.log('running') }) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index a7ffb95..f24f06e 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -48,6 +48,21 @@ const mainpage = { //council 페이지 const council = { + getImages: async (req, res) => { + console.log("home.ctrl의 getImages"); + try { + console.log("university_url: ", university_url); + const response = await University.getImages(req.body.university_url); + return res.json(response); + //1. post-service랑 통신해서 post_img_id, img_url 가져오기 + //2. post_img_id로 클라우드 스토리지에서 이미지 가져오기 + + } catch (err) { + console.log("getImages error", err); + return res.status(500).json({ error: 'Internal Server Error' }); + } + }, + getUniversityName: async (req, res) => { console.log("home.ctrl의 getUniversityName "); const university = new University(); diff --git a/src/models/University.js b/src/models/University.js index 396f78a..8232d12 100644 --- a/src/models/University.js +++ b/src/models/University.js @@ -17,7 +17,7 @@ class University{ async getUnversityUrlToName(university_url){ console.log("University.js의 getUnversityUrlToName\n"); - try{ + try{ const response=await UniversityStorage.getUnversityUrlToName(university_url); return response; }catch(err){ @@ -25,6 +25,11 @@ class University{ } } + async getImages(university_url) { + console.log("University.js의 getImages\n"); + + } + // async getUnversityIdToName(university_id){ // try{ // const response=await UniversityStorage.getUnversityName(university_id); diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 29b163d..4515666 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -47,6 +47,64 @@ class UniversityStorage { }) } + //클라우드 스토리지에서 이미지 가져오기 + static async loadImages(postId) { + return new Promise((resolve, reject) => { + pool.getConnection(async (err, connection) => { + if(err) return reject(err); + + try { + const post_id = postId; + console.log("post_id: ", post_id); + } catch (err) { + connection.release(); + reject({ result: false, status: 500, err: `${err}` }); + } + }); + }); + } + + //게시글 등록시 post이미지 저장(클라우드 스토리지 사용방식으로 변경) + static async saveImagePost(postId, postInfo, formattedDateTime) { + return new Promise((resolve, reject) => { + pool.getConnection(async (err, connection) => { + if (err) return reject(err); + + try { + const post_id = postId; + + // src="data:image/..." 태그에서 base64 이미지 추출 + const regex = //gi; + const matches = postInfo.match(regex); + + if (!matches || matches.length === 0) { + connection.release(); + return resolve({ result: true, status: 201 }); + } + + // 첫 번째 이미지만 처리 (여러 개 저장 원하면 반복문으로 확장 가능) + const base64Image = matches[0].match(/src="([^"]+)"/)[1]; + const base64Data = base64Image.replace(/^data:image\/\w+;base64,/, ""); + const buffer = Buffer.from(base64Data, "base64"); + + const uploadedUrl = await uploadImageToGCS(buffer, `post_${post_id}.jpg`); + + const imageQuery = 'INSERT INTO PostImage(image_id, post_id, image_url, image_date) VALUES (?, ?, ?, ?);'; + connection.query(imageQuery, [null, post_id, uploadedUrl, formattedDateTime], (imageErr) => { + connection.release(); + if (imageErr) { + return reject({ result: false, status: 500, err: `${imageErr}` }); + } + return resolve({ result: true, status: 201 }); + }); + } catch (err) { + connection.release(); + reject({ result: false, status: 500, err: `${err}` }); + } + }); + }); + } + // university_id받아 university_name반환하기 // static getUnversityName(university_id) { diff --git a/src/public/js/council.js b/src/public/js/council.js index 9ecd3aa..851aa22 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -212,6 +212,27 @@ async function fetchImageUrls(imageData) { } } +function imagesLoad() { + console.log("imagesLoad 시작"); //테스트용 로그 + const universityUrl = getUniversityUrl(); + const req = { + university_url: universityUrl + }; + + console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 + fetch(`${apiUrl}/getUniversityName`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + .then((res) => res.json()) + .then(res => { + console.log("여기서 이미지 받아와야 함!"); //테스트용 로그 + }) +} + function councilLoad() { console.log("councilLoad 시작"); //테스트용 로그 const universityUrl = getUniversityUrl(); @@ -256,6 +277,7 @@ function councilLoad() { window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); + imagesLoad(); //포스트 이미지를 가져오는 함수 councilLoad(); // retailerLoad(); }); diff --git a/src/rabbit/rabbitmq.js b/src/rabbit/rabbitmq.js index 2a2298f..79655af 100644 --- a/src/rabbit/rabbitmq.js +++ b/src/rabbit/rabbitmq.js @@ -1,19 +1,19 @@ const amqp = require("amqplib"); const RECV_QUEUES = [ - 'RecvUniversityName', - 'RecvUniversityLocation' -] - + 'RecvStartUniversityName', + 'RecvStartUniversityID', + 'RecvStartUniversityLocation' +]; const SEND_QUEUES = [ - 'SendUniversityName', + 'SendUniversityName', + 'SendUniversityID', 'SendUniversityLocation' -] +]; let channel; async function connectRabbitMQ() { - console.log("Rabbit: ", process.env.RABBIT); const rabbitUrl = process.env.RABBIT || 'amqp://localhost'; // env 변수 사용, 없으면 localhost 기본 const connection = await amqp.connect(rabbitUrl); channel = await connection.createChannel(); @@ -31,10 +31,12 @@ async function sendUniversityURL(university_url, sendQueueName) { if (!channel) await connectRabbitMQ(); let recvQueueName; if(sendQueueName == 'SendUniversityName'){ - recvQueueName = 'RecvUniversityName'; + recvQueueName = 'RecvStartUniversityName'; + } else if(sendQueueName == 'SendUniversityID'){ + recvQueueName = 'RecvStartUniversityID'; } else if(sendQueueName == 'SendUniversityLocation'){ - recvQueueName = 'RecvUniversityLocation' - } else { + recvQueueName = 'RecvStartUniversityLocation' + } else{ console.log("명시되지 않은 sendQueueName 입니다."); } @@ -45,7 +47,6 @@ async function sendUniversityURL(university_url, sendQueueName) { replyTo: recvQueueName, } ); - console.log(`[start-service] university_url 전송: ${university_url} → ${sendQueueName}`); } // university data 수신 @@ -56,21 +57,21 @@ async function receiveUniversityData(queueName) { throw new Error(`알 수 없는 수신 큐: ${queueName}`); } - return new Promise((resolve, reject) => { - channel.consume(queueName, (msg) => { - if (msg) { - const data = JSON.parse(msg.content.toString()); - console.log(`[start-service] ${queueName} 수신:`, data); - channel.ack(msg); // 메시지 확인(ack)해서 큐에서 제거 - resolve(data); - } else { - reject(new Error('메시지를 받지 못했습니다.')); - } - }, { noAck: false }); // noAck: false 로 ack를 직접 호출하게 함 - }); -} + // 최대 10번까지, 300ms 간격으로 메시지 수신 시도 + for (let i = 0; i < 10; i++) { + const msg = await channel.get(queueName, { noAck: false }); + if (msg) { + const data = JSON.parse(msg.content.toString()); + channel.ack(msg); + return data; + } + // 메시지가 없으면 300ms 대기 후 재시도 + await new Promise(resolve => setTimeout(resolve, 300)); + } + throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); +} module.exports = { sendUniversityURL, receiveUniversityData -}; +}; \ No newline at end of file diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 841ec68..467b2b4 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -9,6 +9,8 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); //council 페이지 router.get("/council/:university_url", ctrl.output.council); +router.post("getImages/:university_url", ctrl.council.getImages); + router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); From 7e0c7bf1ed2e963b2e9929cd2ec2c67245003494 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sat, 24 May 2025 07:57:09 +0000 Subject: [PATCH 04/48] =?UTF-8?q?[FEAT]=20getImage=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 7 ++- src/models/University.js | 7 ++- src/models/UniversityStorage.js | 1 + src/public/js/council.js | 23 +++++----- src/rabbit/rabbitMQ.js | 77 +++++++++++++++++++++++++++++++++ src/routes/startRoute.js | 2 +- 6 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 src/rabbit/rabbitMQ.js diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index f24f06e..a0039d9 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -50,9 +50,12 @@ const mainpage = { const council = { getImages: async (req, res) => { console.log("home.ctrl의 getImages"); - try { + const university = new University(); + try { + const university_url = req.body.university_url; console.log("university_url: ", university_url); - const response = await University.getImages(req.body.university_url); + + const response = await university.getImages(university_url); return res.json(response); //1. post-service랑 통신해서 post_img_id, img_url 가져오기 //2. post_img_id로 클라우드 스토리지에서 이미지 가져오기 diff --git a/src/models/University.js b/src/models/University.js index 8232d12..64ac7b8 100644 --- a/src/models/University.js +++ b/src/models/University.js @@ -27,7 +27,12 @@ class University{ async getImages(university_url) { console.log("University.js의 getImages\n"); - + try { + const response = await UniversityStorage.loadImages(university_url); + return response; + } catch (err) { + return{success:false,msg:err}; + } } // async getUnversityIdToName(university_id){ diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 4515666..52ed671 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -49,6 +49,7 @@ class UniversityStorage { //클라우드 스토리지에서 이미지 가져오기 static async loadImages(postId) { + console.log("UniversityStorage의 loadImages"); return new Promise((resolve, reject) => { pool.getConnection(async (err, connection) => { if(err) return reject(err); diff --git a/src/public/js/council.js b/src/public/js/council.js index 851aa22..62ac53a 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -1,8 +1,6 @@ import loadKakaoMap from '/js/kakaomapLoader.js'; import apiKeys from './apiKey.js'; -console.log("council.js 시작1"); //테스트용 로그 - //로그인(로그아웃), 회원가입(마이페이지)버튼 const loginStatusBtn = document.getElementById("loginStatusBtn"); const signUpBtn = document.getElementById("signUpBtn"); @@ -14,8 +12,6 @@ const user_name = document.getElementById("user_name"); const university_name = document.getElementById("university_name"); const navBar=document.getElementById("navbar"); -console.log("council.js 시작"); //테스트용 로그 - //회원로그인 정보 불러오기 // const loadloginData = () => { // const url = `${apiUrl}/loginStatus`; @@ -220,7 +216,7 @@ function imagesLoad() { }; console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 - fetch(`${apiUrl}/getUniversityName`, { + fetch(`${apiUrl}/getImages`, { method: "POST", headers: { "Content-Type": "application/json", @@ -229,19 +225,21 @@ function imagesLoad() { }) .then((res) => res.json()) .then(res => { + console.log("imagesLoad res: ", res); console.log("여기서 이미지 받아와야 함!"); //테스트용 로그 + //fetchImageUrls로 화면에 띄우기 }) } function councilLoad() { - console.log("councilLoad 시작"); //테스트용 로그 + // console.log("councilLoad 시작"); //테스트용 로그 const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl }; - console.log("req:", req);//테스트용 로그 + // console.log("req:", req);//테스트용 로그 - console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 + // console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 fetch(`${apiUrl}/getUniversityName`, { method: "POST", headers: { @@ -253,8 +251,8 @@ function councilLoad() { .then(res => { Uniname.push(res.university_name); universityName.innerHTML = Uniname[0]; - console.log("council의 Uniname[0]: ", Uniname[0]); //테스트용 로그 - console.log("council의 universityName: ", universityName.innerHTML); //테스트용 로그 + // console.log("council의 Uniname[0]: ", Uniname[0]); //테스트용 로그 + // console.log("council의 universityName: ", universityName.innerHTML); //테스트용 로그 }); // .then(() => { // return fetch(`${apiUrl}/getCardNewsImageUrl`, { @@ -366,13 +364,13 @@ function generateDynamicURL(linkId, userschool) { // 새로운 url로 업데이트 async function updateDynamicLinks() { - console.log("updateDynamicLinks 시작"); //테스트용 로그 + // console.log("updateDynamicLinks 시작"); //테스트용 로그 var userschool = getDynamicValueFromURL(); if (!userschool) { console.log("영어 문자열이 URL에서 추출되지 않았습니다."); return; } - console.log("userschool: ", userschool); //테스트용 로그 + // console.log("userschool: ", userschool); //테스트용 로그 var link1 = document.getElementById("main_retailer"); var link2 = document.getElementById("partner"); @@ -410,3 +408,4 @@ async function updateDynamicLinks() { window.location.href = link; }); } + diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js new file mode 100644 index 0000000..1328ee2 --- /dev/null +++ b/src/rabbit/rabbitMQ.js @@ -0,0 +1,77 @@ +const amqp = require("amqplib"); + +const RECV_QUEUES = [ + 'RecvStartUniversityName', + 'RecvStartUniversityID', + 'RecvStartUniversityLocation' +]; +const SEND_QUEUES = [ + 'SendUniversityName', + 'SendUniversityID', + 'SendUniversityLocation' +]; + +let channel; + +async function connectRabbitMQ() { + const rabbitUrl = process.env.RABBIT || 'amqp://localhost'; // env 변수 사용, 없으면 localhost 기본 + const connection = await amqp.connect(rabbitUrl); + channel = await connection.createChannel(); + + // 모든 RECV 큐 선언 + for (const queue of RECV_QUEUES) { + await channel.assertQueue(queue, { durable: false }); + } + + return channel; +} + +// university_url을 전송 +async function sendUniversityURL(university_url, sendQueueName) { + if (!channel) await connectRabbitMQ(); + let recvQueueName; + if(sendQueueName == 'SendUniversityName'){ + recvQueueName = 'RecvStartUniversityName'; + } else if(sendQueueName == 'SendUniversityID'){ + recvQueueName = 'RecvStartUniversityID'; + } else if(sendQueueName == 'SendUniversityLocation'){ + recvQueueName = 'RecvStartUniversityLocation' + } else{ + console.log("명시되지 않은 sendQueueName 입니다."); + } + + channel.sendToQueue( + sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 + Buffer.from(JSON.stringify({ university_url })), + { + replyTo: recvQueueName, + } + ); +} + +// university data 수신 +async function receiveUniversityData(queueName) { + if (!channel) await connectRabbitMQ(); + + if (!RECV_QUEUES.includes(queueName)) { + throw new Error(`알 수 없는 수신 큐: ${queueName}`); + } + + // 최대 10번까지, 300ms 간격으로 메시지 수신 시도 + for (let i = 0; i < 10; i++) { + const msg = await channel.get(queueName, { noAck: false }); + if (msg) { + const data = JSON.parse(msg.content.toString()); + channel.ack(msg); + return data; + } + // 메시지가 없으면 300ms 대기 후 재시도 + await new Promise(resolve => setTimeout(resolve, 300)); + } + + throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); +} +module.exports = { + sendUniversityURL, + receiveUniversityData +}; diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 467b2b4..394dcc3 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -9,7 +9,7 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); //council 페이지 router.get("/council/:university_url", ctrl.output.council); -router.post("getImages/:university_url", ctrl.council.getImages); +router.post("/getImages", ctrl.council.getImages); router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); From 31319c699b6419e3d2ae3a3f738f971ccb0e3f3b Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sat, 24 May 2025 11:01:42 +0000 Subject: [PATCH 05/48] =?UTF-8?q?[TEST]=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 00fb77d..6cb2b76 100644 --- a/main.js +++ b/main.js @@ -51,5 +51,5 @@ app.listen(port, ()=> { console.log('running') }) - +//develop2 branch 연결 테스트 module.exports = app; From eb38a5e352a531b3f0893bfe803f0aa43c98a3cc Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Sun, 25 May 2025 04:09:27 +0900 Subject: [PATCH 06/48] =?UTF-8?q?[FEAT]=20post=20image=20=EB=84=A3?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/UniversityStorage.js | 78 ++++++++++++++++++--------------- src/public/js/council.js | 9 ++-- src/rabbit/rabbitmq.js | 2 +- src/utils/gcsImageUtils.js | 47 ++++++++++++++++++++ src/utils/gcsUploader.js | 28 ------------ 5 files changed, 94 insertions(+), 70 deletions(-) create mode 100644 src/utils/gcsImageUtils.js delete mode 100644 src/utils/gcsUploader.js diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 52ed671..5361633 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -53,10 +53,16 @@ class UniversityStorage { return new Promise((resolve, reject) => { pool.getConnection(async (err, connection) => { if(err) return reject(err); - + try { - const post_id = postId; - console.log("post_id: ", post_id); + const imageData = [ + { + image_url: "https://storage.googleapis.com/uniunity_bucket/고양이이미지.png", + post_id: 1 + } + ]; + resolve(imageData); + } catch (err) { connection.release(); reject({ result: false, status: 500, err: `${err}` }); @@ -66,45 +72,45 @@ class UniversityStorage { } //게시글 등록시 post이미지 저장(클라우드 스토리지 사용방식으로 변경) - static async saveImagePost(postId, postInfo, formattedDateTime) { - return new Promise((resolve, reject) => { - pool.getConnection(async (err, connection) => { - if (err) return reject(err); + // static async saveImagePost(postId, postInfo, formattedDateTime) { + // return new Promise((resolve, reject) => { + // pool.getConnection(async (err, connection) => { + // if (err) return reject(err); - try { - const post_id = postId; + // try { + // const post_id = postId; - // src="data:image/..." 태그에서 base64 이미지 추출 - const regex = //gi; - const matches = postInfo.match(regex); + // // src="data:image/..." 태그에서 base64 이미지 추출 + // const regex = //gi; + // const matches = postInfo.match(regex); - if (!matches || matches.length === 0) { - connection.release(); - return resolve({ result: true, status: 201 }); - } + // if (!matches || matches.length === 0) { + // connection.release(); + // return resolve({ result: true, status: 201 }); + // } - // 첫 번째 이미지만 처리 (여러 개 저장 원하면 반복문으로 확장 가능) - const base64Image = matches[0].match(/src="([^"]+)"/)[1]; - const base64Data = base64Image.replace(/^data:image\/\w+;base64,/, ""); - const buffer = Buffer.from(base64Data, "base64"); + // // 첫 번째 이미지만 처리 (여러 개 저장 원하면 반복문으로 확장 가능) + // const base64Image = matches[0].match(/src="([^"]+)"/)[1]; + // const base64Data = base64Image.replace(/^data:image\/\w+;base64,/, ""); + // const buffer = Buffer.from(base64Data, "base64"); - const uploadedUrl = await uploadImageToGCS(buffer, `post_${post_id}.jpg`); + // const uploadedUrl = await uploadImageToGCS(buffer, `post_${post_id}.jpg`); - const imageQuery = 'INSERT INTO PostImage(image_id, post_id, image_url, image_date) VALUES (?, ?, ?, ?);'; - connection.query(imageQuery, [null, post_id, uploadedUrl, formattedDateTime], (imageErr) => { - connection.release(); - if (imageErr) { - return reject({ result: false, status: 500, err: `${imageErr}` }); - } - return resolve({ result: true, status: 201 }); - }); - } catch (err) { - connection.release(); - reject({ result: false, status: 500, err: `${err}` }); - } - }); - }); - } + // const imageQuery = 'INSERT INTO PostImage(image_id, post_id, image_url, image_date) VALUES (?, ?, ?, ?);'; + // connection.query(imageQuery, [null, post_id, uploadedUrl, formattedDateTime], (imageErr) => { + // connection.release(); + // if (imageErr) { + // return reject({ result: false, status: 500, err: `${imageErr}` }); + // } + // return resolve({ result: true, status: 201 }); + // }); + // } catch (err) { + // connection.release(); + // reject({ result: false, status: 500, err: `${err}` }); + // } + // }); + // }); + // } // university_id받아 university_name반환하기 diff --git a/src/public/js/council.js b/src/public/js/council.js index 62ac53a..11569de 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -165,6 +165,7 @@ var imageUrls = []; // 카드뉴스 이미지 추가 함수 async function fetchImageUrls(imageData) { + console.log('fetchImageUrls 시작'); try { const swiperWrapper = document.querySelector('.swiper-wrapper'); @@ -224,10 +225,8 @@ function imagesLoad() { body: JSON.stringify(req), }) .then((res) => res.json()) - .then(res => { - console.log("imagesLoad res: ", res); - console.log("여기서 이미지 받아와야 함!"); //테스트용 로그 - //fetchImageUrls로 화면에 띄우기 + .then((imageData) => { + fetchImageUrls(imageData); }) } @@ -275,7 +274,7 @@ function councilLoad() { window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); - imagesLoad(); //포스트 이미지를 가져오는 함수 + imagesLoad(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 councilLoad(); // retailerLoad(); }); diff --git a/src/rabbit/rabbitmq.js b/src/rabbit/rabbitmq.js index 79655af..1328ee2 100644 --- a/src/rabbit/rabbitmq.js +++ b/src/rabbit/rabbitmq.js @@ -74,4 +74,4 @@ async function receiveUniversityData(queueName) { module.exports = { sendUniversityURL, receiveUniversityData -}; \ No newline at end of file +}; diff --git a/src/utils/gcsImageUtils.js b/src/utils/gcsImageUtils.js new file mode 100644 index 0000000..9bcaf3e --- /dev/null +++ b/src/utils/gcsImageUtils.js @@ -0,0 +1,47 @@ +// src/utils/gcsUploader.js +const { Storage } = require('@google-cloud/storage'); +const path = require('path'); +const uuid = require('uuid'); +const axios = require('axios'); +require('dotenv').config(); + +const storage = new Storage({ + keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS, +}); +const bucket = storage.bucket('uniunity_bucket'); + +async function getImages(imageUrl) { + try { + const downloadPromises = imageUrls.map(async (url) => { + const response = await axios.get(url, { + responseType: 'arraybuffer', + }); + return Buffer.from(response.data); + }); + + const imageBuffers = await Promise.all(downloadPromises); + return imageBuffers; + } catch (err) { + console.log("gcs 에러", err); + throw err; + } +} + +//post에서 사용하는 함수 +// async function uploadImageToGCS(fileBuffer, originalName) { +// const fileName = `${uuid.v4()}_${originalName}`; +// const file = bucket.file(fileName); + +// await file.save(fileBuffer, { +// resumable: false, +// contentType: 'image/jpeg', +// public: true, +// metadata: { +// cacheControl: 'public, max-age=31536000', +// }, +// }); + +// return `https://storage.googleapis.com/${bucket.name}/${fileName}`; +// } + +module.exports = { getImages }; diff --git a/src/utils/gcsUploader.js b/src/utils/gcsUploader.js deleted file mode 100644 index b46ff9d..0000000 --- a/src/utils/gcsUploader.js +++ /dev/null @@ -1,28 +0,0 @@ -// src/utils/gcsUploader.js -const { Storage } = require('@google-cloud/storage'); -const path = require('path'); -const uuid = require('uuid'); -require('dotenv').config(); - -const storage = new Storage({ - keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS, -}); -const bucket = storage.bucket('uniunity_bucket'); - -async function uploadImageToGCS(fileBuffer, originalName) { - const fileName = `${uuid.v4()}_${originalName}`; - const file = bucket.file(fileName); - - await file.save(fileBuffer, { - resumable: false, - contentType: 'image/jpeg', - public: true, - metadata: { - cacheControl: 'public, max-age=31536000', - }, - }); - - return `https://storage.googleapis.com/${bucket.name}/${fileName}`; -} - -module.exports = { uploadImageToGCS }; From 73f196668f4096b0804f96ada17580f6a46bf5fa Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sat, 24 May 2025 19:23:15 +0000 Subject: [PATCH 07/48] =?UTF-8?q?[FIX]=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 642 ++++++++++++++++++++++++++++++++ package.json | 1 + src/models/UniversityStorage.js | 6 +- src/utils/gcsImageUtils.js | 47 --- 4 files changed, 646 insertions(+), 50 deletions(-) delete mode 100644 src/utils/gcsImageUtils.js diff --git a/package-lock.json b/package-lock.json index dfab410..77099c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@google-cloud/storage": "^7.16.0", "amqplib": "^0.10.8", "bcrypt": "^5.1.1", "cors": "^2.8.5", @@ -21,6 +22,75 @@ "mysql2": "^3.14.1" } }, + "node_modules/@google-cloud/paginator": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@google-cloud/paginator/-/paginator-5.0.2.tgz", + "integrity": "sha512-DJS3s0OVH4zFDB1PzjxAsHqJT6sKVbRwwML0ZBP9PbU7Yebtu/7SWMRzvO2J3nUi9pRNITCfu4LJeooM2w4pjg==", + "license": "Apache-2.0", + "dependencies": { + "arrify": "^2.0.0", + "extend": "^3.0.2" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@google-cloud/projectify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/projectify/-/projectify-4.0.0.tgz", + "integrity": "sha512-MmaX6HeSvyPbWGwFq7mXdo0uQZLGBYCwziiLIGq5JVX+/bdI3SAq6bP98trV5eTWfLuvsMcIC1YJOF2vfteLFA==", + "license": "Apache-2.0", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@google-cloud/promisify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@google-cloud/promisify/-/promisify-4.0.0.tgz", + "integrity": "sha512-Orxzlfb9c67A15cq2JQEyVc7wEsmFBmHjZWZYQMUyJ1qivXyMwdyNOs9odi79hze+2zqdTtu1E19IM/FtqZ10g==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/storage": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-7.16.0.tgz", + "integrity": "sha512-7/5LRgykyOfQENcm6hDKP8SX/u9XxE5YOiWOkgkwcoO+cG8xT/cyOvp9wwN3IxfdYgpHs8CE7Nq2PKX2lNaEXw==", + "license": "Apache-2.0", + "dependencies": { + "@google-cloud/paginator": "^5.0.0", + "@google-cloud/projectify": "^4.0.0", + "@google-cloud/promisify": "<4.1.0", + "abort-controller": "^3.0.0", + "async-retry": "^1.3.3", + "duplexify": "^4.1.3", + "fast-xml-parser": "^4.4.1", + "gaxios": "^6.0.2", + "google-auth-library": "^9.6.3", + "html-entities": "^2.5.2", + "mime": "^3.0.0", + "p-limit": "^3.0.1", + "retry-request": "^7.0.0", + "teeny-request": "^9.0.0", + "uuid": "^8.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@google-cloud/storage/node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/@mapbox/node-pre-gyp": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", @@ -40,11 +110,65 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, + "node_modules/@tootallnate/once": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", + "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/@types/caseless": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.5.tgz", + "integrity": "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==", + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.15.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.21.tgz", + "integrity": "sha512-EV/37Td6c+MgKAbkcLG6vqZ2zEYHD7bvSrzqqs2RIhbA6w3x+Dqz8MZM3sP6kGTeLrdoOgKZe+Xja7tUB2DNkQ==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/request": { + "version": "2.48.12", + "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.12.tgz", + "integrity": "sha512-G3sY+NpsA9jnwm0ixhAFQSJ3Q9JkpLZpJbI3GMv0mIAT0y3mRabYeINzal5WOChIiaTEGQYlHOKgkaM9EisWHw==", + "license": "MIT", + "dependencies": { + "@types/caseless": "*", + "@types/node": "*", + "@types/tough-cookie": "*", + "form-data": "^2.5.0" + } + }, + "node_modules/@types/tough-cookie": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.5.tgz", + "integrity": "sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==", + "license": "MIT" + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/accepts": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", @@ -134,11 +258,35 @@ "node": ">= 6" } }, + "node_modules/arrify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", + "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/async": { "version": "3.2.6", "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==" }, + "node_modules/async-retry": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/async-retry/-/async-retry-1.3.3.tgz", + "integrity": "sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw==", + "license": "MIT", + "dependencies": { + "retry": "0.13.1" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, "node_modules/aws-ssl-profiles": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/aws-ssl-profiles/-/aws-ssl-profiles-1.1.2.tgz", @@ -152,6 +300,26 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/basic-auth": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", @@ -217,6 +385,12 @@ "concat-map": "0.0.1" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, "node_modules/buffer-more-ints": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz", @@ -305,6 +479,18 @@ "color-support": "bin.js" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -391,6 +577,15 @@ } } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -444,6 +639,41 @@ "node": ">= 0.4" } }, + "node_modules/duplexify": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", + "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", + "license": "MIT", + "dependencies": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.2" + } + }, + "node_modules/duplexify/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", @@ -476,6 +706,15 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "license": "MIT", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -503,6 +742,21 @@ "node": ">= 0.4" } }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -516,6 +770,15 @@ "node": ">= 0.6" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/eventemitter3": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", @@ -562,6 +825,30 @@ "url": "https://opencollective.com/express" } }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "license": "MIT" + }, + "node_modules/fast-xml-parser": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.5.3.tgz", + "integrity": "sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT", + "dependencies": { + "strnum": "^1.1.1" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/filelist": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz", @@ -624,6 +911,43 @@ } } }, + "node_modules/form-data": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.3.tgz", + "integrity": "sha512-XHIrMD0NpDrNM/Ckf7XJiBbLl57KEhT3+i3yY+eWm+cqYZJQTZrKo8Y8AWKnuV5GT4scfuUGt9LzNoIx3dU1nQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.35", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -695,6 +1019,71 @@ "node": ">=10" } }, + "node_modules/gaxios": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-6.7.1.tgz", + "integrity": "sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==", + "license": "Apache-2.0", + "dependencies": { + "extend": "^3.0.2", + "https-proxy-agent": "^7.0.1", + "is-stream": "^2.0.0", + "node-fetch": "^2.6.9", + "uuid": "^9.0.1" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/gaxios/node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/gaxios/node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/gaxios/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/gcp-metadata": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-6.1.1.tgz", + "integrity": "sha512-a4tiq7E0/5fTjxPAaH4jpjkSv/uCaU2p5KC6HVGrvl0cDjA8iBZv4vv1gyzlmK0ZUKqwpOyQMKzZQe3lTit77A==", + "license": "Apache-2.0", + "dependencies": { + "gaxios": "^6.1.1", + "google-logging-utils": "^0.0.2", + "json-bigint": "^1.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/generate-function": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz", @@ -758,6 +1147,32 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/google-auth-library": { + "version": "9.15.1", + "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-9.15.1.tgz", + "integrity": "sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==", + "license": "Apache-2.0", + "dependencies": { + "base64-js": "^1.3.0", + "ecdsa-sig-formatter": "^1.0.11", + "gaxios": "^6.1.1", + "gcp-metadata": "^6.1.0", + "gtoken": "^7.0.0", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/google-logging-utils": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-0.0.2.tgz", + "integrity": "sha512-NEgUnEcBiP5HrPzufUkBzJOD/Sxsco3rLNo1F1TNf7ieU8ryUzBhqba8r756CjLX7rn3fHl6iLEwPYuqpoKgQQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=14" + } + }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -769,6 +1184,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/gtoken": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-7.1.0.tgz", + "integrity": "sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==", + "license": "MIT", + "dependencies": { + "gaxios": "^6.0.0", + "jws": "^4.0.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -788,6 +1216,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -823,6 +1266,22 @@ "node": ">=12" } }, + "node_modules/html-entities": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.6.0.tgz", + "integrity": "sha512-kig+rMn/QOVRvr7c86gQ8lWXq+Hkv6CbAH1hLu+RG338StTpE8Z0b44SDVaqVu7HGKf27frdmUYEs9hTUX/cLQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/mdevils" + }, + { + "type": "patreon", + "url": "https://patreon.com/mdevils" + } + ], + "license": "MIT" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -851,6 +1310,20 @@ "node": ">=8.0.0" } }, + "node_modules/http-proxy-agent": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz", + "integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==", + "license": "MIT", + "dependencies": { + "@tootallnate/once": "2", + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/http-server": { "version": "14.1.1", "resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.1.tgz", @@ -947,6 +1420,18 @@ "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==" }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -969,6 +1454,36 @@ "node": ">=10" } }, + "node_modules/json-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", + "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "license": "MIT", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", + "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.0", + "safe-buffer": "^5.0.1" + } + }, "node_modules/long": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", @@ -1302,6 +1817,21 @@ "opener": "bin/opener-bin.js" } }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -1421,6 +1951,29 @@ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/retry-request": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/retry-request/-/retry-request-7.0.2.tgz", + "integrity": "sha512-dUOvLMJ0/JJYEn8NrpOaGNE7X3vpI5XlZS/u0ANjqtcZVKnIxP7IgCFwrKTxENw29emmwug53awKtaMm4i9g5w==", + "license": "MIT", + "dependencies": { + "@types/request": "^2.48.8", + "extend": "^3.0.2", + "teeny-request": "^9.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1630,6 +2183,21 @@ "node": ">= 0.8" } }, + "node_modules/stream-events": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", + "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==", + "license": "MIT", + "dependencies": { + "stubs": "^3.0.0" + } + }, + "node_modules/stream-shift": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", + "license": "MIT" + }, "node_modules/string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -1667,6 +2235,24 @@ "node": ">=8" } }, + "node_modules/strnum": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.1.2.tgz", + "integrity": "sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + } + ], + "license": "MIT" + }, + "node_modules/stubs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", + "integrity": "sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==", + "license": "MIT" + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -1694,6 +2280,35 @@ "node": ">=10" } }, + "node_modules/teeny-request": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-9.0.0.tgz", + "integrity": "sha512-resvxdc6Mgb7YEThw6G6bExlXKkv6+YbuzGg9xuXxSgxJF7Ozs+o8Y9+2R3sArdWdW8nOokoQb1yrpFB0pQK2g==", + "license": "Apache-2.0", + "dependencies": { + "http-proxy-agent": "^5.0.0", + "https-proxy-agent": "^5.0.0", + "node-fetch": "^2.6.9", + "stream-events": "^1.0.5", + "uuid": "^9.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/teeny-request/node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -1720,6 +2335,12 @@ "node": ">= 0.6" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, "node_modules/union": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz", @@ -1759,6 +2380,15 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -1809,6 +2439,18 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index 526afd1..781a2ec 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "@google-cloud/storage": "^7.16.0", "amqplib": "^0.10.8", "bcrypt": "^5.1.1", "cors": "^2.8.5", diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index 5361633..eaa86c5 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -1,7 +1,6 @@ "use strict" const { pool } = require("../config/db"); -const { uploadImageToGCS } = require("../utils/gcsUploader"); class UniversityStorage { //모든 대학 정보 가져오기 @@ -47,14 +46,15 @@ class UniversityStorage { }) } - //클라우드 스토리지에서 이미지 가져오기 - static async loadImages(postId) { + //이미지 정보 넘기 + static async loadI기mages(postId) { console.log("UniversityStorage의 loadImages"); return new Promise((resolve, reject) => { pool.getConnection(async (err, connection) => { if(err) return reject(err); try { + //post랑 통신해서 post_id, img_url 받아와야 해서 일단 하드코딩 해뒀음 const imageData = [ { image_url: "https://storage.googleapis.com/uniunity_bucket/고양이이미지.png", diff --git a/src/utils/gcsImageUtils.js b/src/utils/gcsImageUtils.js deleted file mode 100644 index 9bcaf3e..0000000 --- a/src/utils/gcsImageUtils.js +++ /dev/null @@ -1,47 +0,0 @@ -// src/utils/gcsUploader.js -const { Storage } = require('@google-cloud/storage'); -const path = require('path'); -const uuid = require('uuid'); -const axios = require('axios'); -require('dotenv').config(); - -const storage = new Storage({ - keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS, -}); -const bucket = storage.bucket('uniunity_bucket'); - -async function getImages(imageUrl) { - try { - const downloadPromises = imageUrls.map(async (url) => { - const response = await axios.get(url, { - responseType: 'arraybuffer', - }); - return Buffer.from(response.data); - }); - - const imageBuffers = await Promise.all(downloadPromises); - return imageBuffers; - } catch (err) { - console.log("gcs 에러", err); - throw err; - } -} - -//post에서 사용하는 함수 -// async function uploadImageToGCS(fileBuffer, originalName) { -// const fileName = `${uuid.v4()}_${originalName}`; -// const file = bucket.file(fileName); - -// await file.save(fileBuffer, { -// resumable: false, -// contentType: 'image/jpeg', -// public: true, -// metadata: { -// cacheControl: 'public, max-age=31536000', -// }, -// }); - -// return `https://storage.googleapis.com/${bucket.name}/${fileName}`; -// } - -module.exports = { getImages }; From 1a8a251632234410cbe2e31e1742a8747d7419ad Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sat, 24 May 2025 19:43:09 +0000 Subject: [PATCH 08/48] =?UTF-8?q?[FIX]=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/UniversityStorage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index eaa86c5..cf3753a 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -47,7 +47,7 @@ class UniversityStorage { } //이미지 정보 넘기 - static async loadI기mages(postId) { + static async loadImages(postId) { console.log("UniversityStorage의 loadImages"); return new Promise((resolve, reject) => { pool.getConnection(async (err, connection) => { @@ -59,6 +59,14 @@ class UniversityStorage { { image_url: "https://storage.googleapis.com/uniunity_bucket/고양이이미지.png", post_id: 1 + }, + { + image_url: "https://storage.googleapis.com/uniunity_bucket/고양이이미지.png", + post_id: 2 + }, + { + image_url: "https://storage.googleapis.com/uniunity_bucket/고양이이미지.png", + post_id: 3 } ]; resolve(imageData); From 291c9fc8fe8bb0ecd5c63173e42200bea01b4249 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sun, 25 May 2025 06:37:42 +0000 Subject: [PATCH 09/48] =?UTF-8?q?[FIX]=20=ED=95=84=EC=9A=94=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20rabbitmq=EA=B4=80=EB=A0=A8=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 7 +--- src/controllers/home.ctrl.js | 2 +- src/rabbit/rabbitmq-api.js | 23 ----------- src/rabbit/rabbitmq.js | 77 ------------------------------------ 4 files changed, 2 insertions(+), 107 deletions(-) delete mode 100644 src/rabbit/rabbitmq-api.js delete mode 100644 src/rabbit/rabbitmq.js diff --git a/main.js b/main.js index 6cb2b76..0be95ca 100644 --- a/main.js +++ b/main.js @@ -6,7 +6,7 @@ const bodyParser = require("body-parser"); const path = require('path'); const db = require('./src/config/db.js'); const app = express(); -const rabbitmq = require("./src/rabbit/rabbitmq.js") +const rabbitmq = require("./src/rabbit/rabbitMQ.js") //에러 라우팅 const errorController = require("./src/controllers/errorControllers.js"); @@ -41,11 +41,6 @@ app.use(errorController.logErrors); app.use(errorController.respondNoResourceFound); app.use(errorController.respondInternalEroor); -//래빗mq -//const mq = require("./src/rabbit/rabbitmq-api.js"); -//app.post("/send_msg", mq.send_message); -//app.get("/get_msg", mq.recv_message); - const port = process.env.PORT; app.listen(port, ()=> { console.log('running') diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index a0039d9..e44caa4 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -1,7 +1,7 @@ "use strict" const University = require("../models/University"); -const { sendUniversityURL, receiveUniversityData } = require('../rabbit/rabbitmq'); +const { sendUniversityURL, receiveUniversityData } = require('../rabbit/rabbitMQ'); //const Partner = require("../models/Partner"); // const User = require("../models/User"); // const Council = require("../models/Council"); diff --git a/src/rabbit/rabbitmq-api.js b/src/rabbit/rabbitmq-api.js deleted file mode 100644 index 305cadf..0000000 --- a/src/rabbit/rabbitmq-api.js +++ /dev/null @@ -1,23 +0,0 @@ -const Rabbitmq = require("./rabbitmq.js"); -const url = "amqp://34.47.84.123:5672"; //rabbitmq url -const queue = "web_msg"; //임시 queue이름이고 필요한 상황에 맞게 이름 따로 지정해줘야 한다. -module.exports = { - send_message: async (req, res) => { - try { - let { msg } = req.body; - const conn = new Rabbitmq(url, queue); - - await conn.send_message(msg); - res.status(200).json({ result: true }); - } catch (error) { - console.log(error); - } - }, - recv_message: async (req, res) => { - try { - const conn = new Rabbitmq(url, queue); - const msg = await conn.recv_message(); - res.status(200).json({ result: msg }); - } catch (error) {} - }, -}; diff --git a/src/rabbit/rabbitmq.js b/src/rabbit/rabbitmq.js deleted file mode 100644 index 1328ee2..0000000 --- a/src/rabbit/rabbitmq.js +++ /dev/null @@ -1,77 +0,0 @@ -const amqp = require("amqplib"); - -const RECV_QUEUES = [ - 'RecvStartUniversityName', - 'RecvStartUniversityID', - 'RecvStartUniversityLocation' -]; -const SEND_QUEUES = [ - 'SendUniversityName', - 'SendUniversityID', - 'SendUniversityLocation' -]; - -let channel; - -async function connectRabbitMQ() { - const rabbitUrl = process.env.RABBIT || 'amqp://localhost'; // env 변수 사용, 없으면 localhost 기본 - const connection = await amqp.connect(rabbitUrl); - channel = await connection.createChannel(); - - // 모든 RECV 큐 선언 - for (const queue of RECV_QUEUES) { - await channel.assertQueue(queue, { durable: false }); - } - - return channel; -} - -// university_url을 전송 -async function sendUniversityURL(university_url, sendQueueName) { - if (!channel) await connectRabbitMQ(); - let recvQueueName; - if(sendQueueName == 'SendUniversityName'){ - recvQueueName = 'RecvStartUniversityName'; - } else if(sendQueueName == 'SendUniversityID'){ - recvQueueName = 'RecvStartUniversityID'; - } else if(sendQueueName == 'SendUniversityLocation'){ - recvQueueName = 'RecvStartUniversityLocation' - } else{ - console.log("명시되지 않은 sendQueueName 입니다."); - } - - channel.sendToQueue( - sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 - Buffer.from(JSON.stringify({ university_url })), - { - replyTo: recvQueueName, - } - ); -} - -// university data 수신 -async function receiveUniversityData(queueName) { - if (!channel) await connectRabbitMQ(); - - if (!RECV_QUEUES.includes(queueName)) { - throw new Error(`알 수 없는 수신 큐: ${queueName}`); - } - - // 최대 10번까지, 300ms 간격으로 메시지 수신 시도 - for (let i = 0; i < 10; i++) { - const msg = await channel.get(queueName, { noAck: false }); - if (msg) { - const data = JSON.parse(msg.content.toString()); - channel.ack(msg); - return data; - } - // 메시지가 없으면 300ms 대기 후 재시도 - await new Promise(resolve => setTimeout(resolve, 300)); - } - - throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); -} -module.exports = { - sendUniversityURL, - receiveUniversityData -}; From 4606e7e82e8bc60e54a59db84426d890c5bd518d Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sun, 25 May 2025 07:11:02 +0000 Subject: [PATCH 10/48] =?UTF-8?q?[FEAT]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 11569de..56de933 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -12,6 +12,22 @@ const user_name = document.getElementById("user_name"); const university_name = document.getElementById("university_name"); const navBar=document.getElementById("navbar"); +//auth 로그인 정보 가져오기 +let userInfo; + +const loadloginData = async () => { + const res = await fetch("/auth/me", { + credentials: "include", // 쿠키 포함 + }); + + userInfo = await res.json(); // 유저 정보가 저장되는 변수 +}; + +// 페이지 로드 후 로그인 정보 획득 +window.addEventListener('DOMContentLoaded', function () { + loadloginData(); +}); + //회원로그인 정보 불러오기 // const loadloginData = () => { // const url = `${apiUrl}/loginStatus`; @@ -41,11 +57,6 @@ const navBar=document.getElementById("navbar"); // } -// 로드 후 loadData()실행 -// window.addEventListener('DOMContentLoaded', function () { -// loadloginData(); -// }); - // university_url 값을 받아오는 함수 function getUniversityUrl() { From c9788745ad772ee204d991968372bf6c0a56ec28 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Sun, 25 May 2025 16:57:17 +0900 Subject: [PATCH 11/48] =?UTF-8?q?[FEAT]=20rabbitmq=20=ED=86=B5=EC=8B=A0=20?= =?UTF-8?q?=EC=8B=9C=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 58 +++++++++++++++--------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index e44caa4..3b7a7c1 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -2,14 +2,6 @@ const University = require("../models/University"); const { sendUniversityURL, receiveUniversityData } = require('../rabbit/rabbitMQ'); -//const Partner = require("../models/Partner"); -// const User = require("../models/User"); -// const Council = require("../models/Council"); -// const Post = require("../models/Post"); -// const sendEmailWithAuthorization = require("../../mailer"); -// const bcrypt = require('bcrypt'); -// const Comment = require('../models/Comment'); -// const { getLatestPosts } = require("../public/js/post/post"); const output = { home: (req, res) => { @@ -27,23 +19,7 @@ const mainpage = { const university = new University(); const response = await university.showUniversityNameList(); return res.json(response); - }, - - - getUniversityName: async (req, res) => { - console.log("home.ctrl의 getUniversityName "); - console.log("req.body:", req.body); - - if (!req.body || !req.body.university_url) { - console.error("❌ university_url이 전달되지 않았습니다."); - return res.status(400).json({ error: "university_url이 필요합니다." }); - } - - const university = new University(); - const response = await university.getUniversityName(req.body.university_url); - console.log(response); - return res.json(response); - }, + } } //council 페이지 @@ -67,17 +43,31 @@ const council = { }, getUniversityName: async (req, res) => { - console.log("home.ctrl의 getUniversityName "); - const university = new University(); - - if (!req.body || !req.body.university_url) { - console.error("❌ university_url이 전달되지 않았습니다."); - return res.status(400).json({ error: "university_url이 필요합니다." }); + try { + console.log("home.ctrl의 getUniversityName "); + const universtiy_url = req.body.university_url; + await sendUniversityURL(universtiy_url, 'SendUniversityName') + const university_name = await receiveUniversityData('RecvStartUniversityName'); + console.log("home: university name:", university_name); + return res.json(university_name); + + } catch (err) { + console.error('getUniversityName error:', err); + return res.status(500).json({ error: 'Internal Server Error' }); } - const response = await university.getUnversityUrlToName(req.body.university_url); - console.log(response); - return res.json(response); + //rabbitmq 적용 전 코드 + // console.log("home.ctrl의 getUniversityName "); + // const university = new University(); + + // if (!req.body || !req.body.university_url) { + // console.error("❌ university_url이 전달되지 않았습니다."); + // return res.status(400).json({ error: "university_url이 필요합니다." }); + // } + + // const response = await university.getUnversityUrlToName(req.body.university_url); + // console.log(response); + // return res.json(response); }, getUniversityLocation: async (req, res) => { From 6650f5df6a4964b57349a1c6dff1851464491bb5 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Sun, 25 May 2025 17:36:00 +0900 Subject: [PATCH 12/48] =?UTF-8?q?[FEAT]=20university=5Fid=20=EB=B0=9B?= =?UTF-8?q?=EC=95=84=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 9 ++++++-- src/models/University.js | 19 ++++++++-------- src/models/UniversityStorage.js | 39 +++++++++++++++++---------------- src/public/js/apiUrl.js | 1 - src/public/js/council.js | 7 +----- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 3b7a7c1..1fc5426 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -46,10 +46,15 @@ const council = { try { console.log("home.ctrl의 getUniversityName "); const universtiy_url = req.body.university_url; - await sendUniversityURL(universtiy_url, 'SendUniversityName') + //rabbitMQ로 user-service에 university_name, id 요청 + await sendUniversityURL(universtiy_url, 'SendUniversityName'); + await sendUniversityURL(universtiy_url, 'SendUniversityID'); + + //데이터 수신 const university_name = await receiveUniversityData('RecvStartUniversityName'); + const university_id = await receiveUniversityData('RecvStartUniversityID'); console.log("home: university name:", university_name); - return res.json(university_name); + return res.json({university_name, university_id}); } catch (err) { console.error('getUniversityName error:', err); diff --git a/src/models/University.js b/src/models/University.js index 64ac7b8..9a0b1d2 100644 --- a/src/models/University.js +++ b/src/models/University.js @@ -15,15 +15,16 @@ class University{ } } - async getUnversityUrlToName(university_url){ - console.log("University.js의 getUnversityUrlToName\n"); - try{ - const response=await UniversityStorage.getUnversityUrlToName(university_url); - return response; - }catch(err){ - return{success:false,msg:err}; - } - } + // rabbitMQ로 대체 + // async getUnversityUrlToName(university_url){ + // console.log("University.js의 getUnversityUrlToName\n"); + // try{ + // const response=await UniversityStorage.getUnversityUrlToName(university_url); + // return response; + // }catch(err){ + // return{success:false,msg:err}; + // } + // } async getImages(university_url) { console.log("University.js의 getImages\n"); diff --git a/src/models/UniversityStorage.js b/src/models/UniversityStorage.js index cf3753a..4eb15ff 100644 --- a/src/models/UniversityStorage.js +++ b/src/models/UniversityStorage.js @@ -25,26 +25,27 @@ class UniversityStorage { }) } - static getUnversityUrlToName(university_url) { - console.log("UniversityStorage.js의 getUnversityUrlToName") - return new Promise(async (resolve, reject) => { - pool.getConnection((err, connection) => { - if (err) { - console.error('getUnversityName MySQL 연결 오류: ', err); - reject(err) - } - const query = "SELECT university_name FROM University WHERE university_url =?;"; - pool.query(query, [university_url], (err, data) => { - connection.release(); - if (err) reject(`${err}`); + // rabbitMQ로 대체 + // static getUnversityUrlToName(university_url) { + // console.log("UniversityStorage.js의 getUnversityUrlToName") + // return new Promise(async (resolve, reject) => { + // pool.getConnection((err, connection) => { + // if (err) { + // console.error('getUnversityName MySQL 연결 오류: ', err); + // reject(err) + // } + // const query = "SELECT university_name FROM University WHERE university_url =?;"; + // pool.query(query, [university_url], (err, data) => { + // connection.release(); + // if (err) reject(`${err}`); - else { - resolve(data[0].university_name); - } - }); - }) - }) - } + // else { + // resolve(data[0].university_name); + // } + // }); + // }) + // }) + // } //이미지 정보 넘기 static async loadImages(postId) { diff --git a/src/public/js/apiUrl.js b/src/public/js/apiUrl.js index a8c0071..7baa4bc 100644 --- a/src/public/js/apiUrl.js +++ b/src/public/js/apiUrl.js @@ -1,3 +1,2 @@ // config.js -console.log("apiUrl.js 연결") //테스트용 로그 const apiUrl = 'http://34.47.84.123:3001'; diff --git a/src/public/js/council.js b/src/public/js/council.js index 56de933..86c4080 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -153,7 +153,6 @@ document.addEventListener("DOMContentLoaded", () => { // 슬라이더 정보 var mySwiper; function setSwiper() { - console.log("setSwiper 시작"); //테스트용 로그 mySwiper = new Swiper('.swiper-container', { wrapperClass: 'swiper-wrapper', slideClass: 'swiper-slide', @@ -242,14 +241,11 @@ function imagesLoad() { } function councilLoad() { - // console.log("councilLoad 시작"); //테스트용 로그 const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl }; - // console.log("req:", req);//테스트용 로그 - // console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 fetch(`${apiUrl}/getUniversityName`, { method: "POST", headers: { @@ -259,6 +255,7 @@ function councilLoad() { }) .then((res) => res.json()) .then(res => { + console.log("councilLoad universityInfo: ", res); Uniname.push(res.university_name); universityName.innerHTML = Uniname[0]; // console.log("council의 Uniname[0]: ", Uniname[0]); //테스트용 로그 @@ -374,13 +371,11 @@ function generateDynamicURL(linkId, userschool) { // 새로운 url로 업데이트 async function updateDynamicLinks() { - // console.log("updateDynamicLinks 시작"); //테스트용 로그 var userschool = getDynamicValueFromURL(); if (!userschool) { console.log("영어 문자열이 URL에서 추출되지 않았습니다."); return; } - // console.log("userschool: ", userschool); //테스트용 로그 var link1 = document.getElementById("main_retailer"); var link2 = document.getElementById("partner"); From e17546b30e572120e17b35ae9921c62ace9ef0c0 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sun, 25 May 2025 09:05:33 +0000 Subject: [PATCH 13/48] =?UTF-8?q?[FIX]=20=ED=95=99=EA=B5=90=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 1fc5426..f388f39 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -45,16 +45,14 @@ const council = { getUniversityName: async (req, res) => { try { console.log("home.ctrl의 getUniversityName "); - const universtiy_url = req.body.university_url; + const university_url = req.body.university_url; //rabbitMQ로 user-service에 university_name, id 요청 - await sendUniversityURL(universtiy_url, 'SendUniversityName'); - await sendUniversityURL(universtiy_url, 'SendUniversityID'); + await sendUniversityURL(university_url, 'SendUniversityName'); //데이터 수신 const university_name = await receiveUniversityData('RecvStartUniversityName'); - const university_id = await receiveUniversityData('RecvStartUniversityID'); - console.log("home: university name:", university_name); - return res.json({university_name, university_id}); + console.log("home: university name:", university_name.university_name); + return res.json(university_name); } catch (err) { console.error('getUniversityName error:', err); From 4dc87994e13a9571cc23b14e6e697f577cae864a Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Mon, 26 May 2025 03:07:50 +0900 Subject: [PATCH 14/48] =?UTF-8?q?[FEAT]=20rabbitMQ=20=ED=81=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit post와 통신하기 위한 코드를 추가함 --- src/controllers/home.ctrl.js | 29 +++++++++++++++++++++++------ src/public/js/council.js | 33 ++++++++++++++++++++++++++++++--- src/rabbit/rabbitMQ.js | 23 +++++++++++++++++++++-- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index f388f39..8511c5a 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -1,7 +1,7 @@ "use strict" const University = require("../models/University"); -const { sendUniversityURL, receiveUniversityData } = require('../rabbit/rabbitMQ'); +const { sendUniversityURL, sendUniversityID, receiveUniversityData } = require('../rabbit/rabbitMQ'); const output = { home: (req, res) => { @@ -24,18 +24,35 @@ const mainpage = { //council 페이지 const council = { + getUniversityID: async (req, res) => { + try { + console.log("home.ctrl의 getUniversityID "); + const university_url = req.body.university_url; + await sendUniversityURL(university_url, 'SendUniversityID'); + + //데이터 수신 + const university_id = await receiveUniversityData('RecvStartUniversityID'); + console.log("home: university id:", university_name.university_id); + return university_id; + } catch (err) { + console.log("getUniversityID error", err); + return res.status(500).json({ error: 'Internal Server Error' }); + } + }, + getImages: async (req, res) => { console.log("home.ctrl의 getImages"); const university = new University(); - try { - const university_url = req.body.university_url; + try { + //1. url로 id 얻어오기 + //2. post-service랑 통신해서 post_img_id, img_url 가져오기 + + //------- + const university_url = req.body.university_url; console.log("university_url: ", university_url); const response = await university.getImages(university_url); return res.json(response); - //1. post-service랑 통신해서 post_img_id, img_url 가져오기 - //2. post_img_id로 클라우드 스토리지에서 이미지 가져오기 - } catch (err) { console.log("getImages error", err); return res.status(500).json({ error: 'Internal Server Error' }); diff --git a/src/public/js/council.js b/src/public/js/council.js index 86c4080..276c44e 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -240,7 +240,7 @@ function imagesLoad() { }) } -function councilLoad() { +function councilLoad() { //-> nameLoad const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl @@ -279,12 +279,39 @@ function councilLoad() { // }); } +//------------------- +//1. url -> name +function nameLoad() { + const universityUrl = getUniversityUrl(); + const req = { + university_url: universityUrl + + }; + + fetch(`${apiUrl}/getUniversityName`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + .then((res) => res.json()) + .then(res => { + console.log("councilLoad universityInfo: ", res); + Uniname.push(res.university_name); + universityName.innerHTML = Uniname[0]; + }); +} +//2. id -> post_id, img_url +//3. url -> location +//------------------- + window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); imagesLoad(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 - councilLoad(); - // retailerLoad(); + //councilLoad(); + nameLoad(); }); diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js index 1328ee2..dad91ee 100644 --- a/src/rabbit/rabbitMQ.js +++ b/src/rabbit/rabbitMQ.js @@ -3,12 +3,14 @@ const amqp = require("amqplib"); const RECV_QUEUES = [ 'RecvStartUniversityName', 'RecvStartUniversityID', - 'RecvStartUniversityLocation' + 'RecvStartUniversityLocation', + 'RecvStartPostInfo' ]; const SEND_QUEUES = [ 'SendUniversityName', 'SendUniversityID', - 'SendUniversityLocation' + 'SendUniversityLocation', + 'SendPostInfo' ]; let channel; @@ -71,7 +73,24 @@ async function receiveUniversityData(queueName) { throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); } + +async function sendUniversityID(university_id, sendQueueName) { + if (!channel) await connectRabbitMQ(); + channel.sendToQueue( + sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 + Buffer.from(JSON.stringify({ university_id })), + { + replyTo: 'RecvStartPostInfo', + } + ); +} + +async function receivePostInfo(queueName) { + if (!channel) await connectRabbitMQ(); +} + module.exports = { sendUniversityURL, + sendUniversityID, receiveUniversityData }; From 4a8a8773c946e48395e37d09db6e8013ab96ce3b Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Mon, 26 May 2025 03:31:46 +0900 Subject: [PATCH 15/48] [FEAT] getUniversityID --- src/controllers/home.ctrl.js | 4 ++-- src/public/js/council.js | 35 +++++++++++++++++++++++++++++------ src/routes/startRoute.js | 3 ++- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 8511c5a..e990eee 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -32,8 +32,8 @@ const council = { //데이터 수신 const university_id = await receiveUniversityData('RecvStartUniversityID'); - console.log("home: university id:", university_name.university_id); - return university_id; + console.log("home: university id:", university_id); + return res.json(university_name); } catch (err) { console.log("getUniversityID error", err); return res.status(500).json({ error: 'Internal Server Error' }); diff --git a/src/public/js/council.js b/src/public/js/council.js index 276c44e..d10c1bd 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -219,8 +219,8 @@ async function fetchImageUrls(imageData) { } } -function imagesLoad() { - console.log("imagesLoad 시작"); //테스트용 로그 +function imagesLoadTest() { + console.log("imagesLoadTest 시작"); //테스트용 로그 const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl @@ -285,7 +285,6 @@ function nameLoad() { const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl - }; fetch(`${apiUrl}/getUniversityName`, { @@ -302,14 +301,38 @@ function nameLoad() { universityName.innerHTML = Uniname[0]; }); } -//2. id -> post_id, img_url -//3. url -> location +//2. url -> id +function idLoad() { + const universityUrl = getUniversityUrl(); + const req = { + university_url: universityUrl + }; + + fetch(`${apiUrl}/getUniversityID`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + .then((res) => res.json()) + .then(res => { + console.log("idLoad univ_id: ", res); + }); +} + +//3. id -> post_id, img_url +function imageLoad() { + +} + +//4. url -> location //------------------- window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); - imagesLoad(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 + imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); }); diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 394dcc3..2499cda 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -9,9 +9,10 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); //council 페이지 router.get("/council/:university_url", ctrl.output.council); +router.post("/getUniversityName", ctrl.council.getUniversityName); +router.post("/getUniversityID", ctrl.council.getUniversityID); router.post("/getImages", ctrl.council.getImages); -router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); // council 라우터 From 74d69291d1e46d077687daaaedb36316bf19cffb Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Mon, 26 May 2025 03:41:10 +0900 Subject: [PATCH 16/48] =?UTF-8?q?[FIX]=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 2 +- src/public/js/council.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index e990eee..64fe315 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -33,7 +33,7 @@ const council = { //데이터 수신 const university_id = await receiveUniversityData('RecvStartUniversityID'); console.log("home: university id:", university_id); - return res.json(university_name); + return res.json(university_id); } catch (err) { console.log("getUniversityID error", err); return res.status(500).json({ error: 'Internal Server Error' }); diff --git a/src/public/js/council.js b/src/public/js/council.js index d10c1bd..06aa52b 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -335,6 +335,7 @@ window.addEventListener('DOMContentLoaded', function() { imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); + idLoad(); }); From 48296dbb9e1e018e679820bc4f87a2cb2d67b449 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Mon, 26 May 2025 04:19:27 +0900 Subject: [PATCH 17/48] =?UTF-8?q?[FEAT]=20imageLoad=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 7 ++---- src/public/js/council.js | 49 +++++++++++++++++++++--------------- src/routes/startRoute.js | 2 +- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 64fe315..c9f60a2 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -40,14 +40,11 @@ const council = { } }, - getImages: async (req, res) => { + getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); const university = new University(); try { - //1. url로 id 얻어오기 - //2. post-service랑 통신해서 post_img_id, img_url 가져오기 - - //------- + //간접통신으로 바꾸기 const university_url = req.body.university_url; console.log("university_url: ", university_url); diff --git a/src/public/js/council.js b/src/public/js/council.js index 06aa52b..e897974 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -69,7 +69,7 @@ function getUniversityUrl() { console.log("universityUrl: ", universityUrl); return universityUrl; } -var university_url = getUniversityUrl(); +var current_university_url = getUniversityUrl(); function setCenter(map,latitude,longitude){ // 이동할 위도 경도 위치를 생성합니다 @@ -221,9 +221,9 @@ async function fetchImageUrls(imageData) { function imagesLoadTest() { console.log("imagesLoadTest 시작"); //테스트용 로그 - const universityUrl = getUniversityUrl(); + //const universityUrl = getUniversityUrl(); const req = { - university_url: universityUrl + university_url: current_university_url }; console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 @@ -241,9 +241,9 @@ function imagesLoadTest() { } function councilLoad() { //-> nameLoad - const universityUrl = getUniversityUrl(); + //const universityUrl = getUniversityUrl(); const req = { - university_url: universityUrl + university_url: current_university_url }; fetch(`${apiUrl}/getUniversityName`, { @@ -282,9 +282,9 @@ function councilLoad() { //-> nameLoad //------------------- //1. url -> name function nameLoad() { - const universityUrl = getUniversityUrl(); + //const universityUrl = getUniversityUrl(); const req = { - university_url: universityUrl + university_url: current_university_url }; fetch(`${apiUrl}/getUniversityName`, { @@ -301,11 +301,11 @@ function nameLoad() { universityName.innerHTML = Uniname[0]; }); } -//2. url -> id -function idLoad() { - const universityUrl = getUniversityUrl(); +//2. url -> id -> post_id, img_url +function imageLoad() { + //const universityUrl = getUniversityUrl(); const req = { - university_url: universityUrl + university_url: current_university_url }; fetch(`${apiUrl}/getUniversityID`, { @@ -317,25 +317,34 @@ function idLoad() { }) .then((res) => res.json()) .then(res => { - console.log("idLoad univ_id: ", res); - }); -} + console.log("idLoad univ_id: ", res); //테스트용 로그 + req = { + university_id: current_university_id + } + }) + .then(() => { + return fetch(`${apiUrl}/getCardNewsImageUrl`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + } -//3. id -> post_id, img_url -function imageLoad() { - + ); } -//4. url -> location +//3. url -> location //------------------- window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); - imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 + //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - idLoad(); + imageLoad(); }); diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 2499cda..b3efd96 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -11,7 +11,7 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); router.get("/council/:university_url", ctrl.output.council); router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityID", ctrl.council.getUniversityID); -router.post("/getImages", ctrl.council.getImages); +router.post("/getCardNewsImageUrl", ctrl.council.getImages); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); From ee3a31c3bd1ad7b5757a68710aa87eb8f4364dcc Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sun, 25 May 2025 19:42:13 +0000 Subject: [PATCH 18/48] =?UTF-8?q?Revert=20"[FEAT]=20imageLoad=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 48296dbb9e1e018e679820bc4f87a2cb2d67b449. --- src/controllers/home.ctrl.js | 7 ++++-- src/public/js/council.js | 49 +++++++++++++++--------------------- src/routes/startRoute.js | 2 +- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index c9f60a2..64fe315 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -40,11 +40,14 @@ const council = { } }, - getCardNewsImageUrl: async (req, res) => { + getImages: async (req, res) => { console.log("home.ctrl의 getImages"); const university = new University(); try { - //간접통신으로 바꾸기 + //1. url로 id 얻어오기 + //2. post-service랑 통신해서 post_img_id, img_url 가져오기 + + //------- const university_url = req.body.university_url; console.log("university_url: ", university_url); diff --git a/src/public/js/council.js b/src/public/js/council.js index e897974..06aa52b 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -69,7 +69,7 @@ function getUniversityUrl() { console.log("universityUrl: ", universityUrl); return universityUrl; } -var current_university_url = getUniversityUrl(); +var university_url = getUniversityUrl(); function setCenter(map,latitude,longitude){ // 이동할 위도 경도 위치를 생성합니다 @@ -221,9 +221,9 @@ async function fetchImageUrls(imageData) { function imagesLoadTest() { console.log("imagesLoadTest 시작"); //테스트용 로그 - //const universityUrl = getUniversityUrl(); + const universityUrl = getUniversityUrl(); const req = { - university_url: current_university_url + university_url: universityUrl }; console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 @@ -241,9 +241,9 @@ function imagesLoadTest() { } function councilLoad() { //-> nameLoad - //const universityUrl = getUniversityUrl(); + const universityUrl = getUniversityUrl(); const req = { - university_url: current_university_url + university_url: universityUrl }; fetch(`${apiUrl}/getUniversityName`, { @@ -282,9 +282,9 @@ function councilLoad() { //-> nameLoad //------------------- //1. url -> name function nameLoad() { - //const universityUrl = getUniversityUrl(); + const universityUrl = getUniversityUrl(); const req = { - university_url: current_university_url + university_url: universityUrl }; fetch(`${apiUrl}/getUniversityName`, { @@ -301,11 +301,11 @@ function nameLoad() { universityName.innerHTML = Uniname[0]; }); } -//2. url -> id -> post_id, img_url -function imageLoad() { - //const universityUrl = getUniversityUrl(); +//2. url -> id +function idLoad() { + const universityUrl = getUniversityUrl(); const req = { - university_url: current_university_url + university_url: universityUrl }; fetch(`${apiUrl}/getUniversityID`, { @@ -317,34 +317,25 @@ function imageLoad() { }) .then((res) => res.json()) .then(res => { - console.log("idLoad univ_id: ", res); //테스트용 로그 - req = { - university_id: current_university_id - } - }) - .then(() => { - return fetch(`${apiUrl}/getCardNewsImageUrl`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(req), - }) - } + console.log("idLoad univ_id: ", res); + }); +} - ); +//3. id -> post_id, img_url +function imageLoad() { + } -//3. url -> location +//4. url -> location //------------------- window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); - //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 + imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - imageLoad(); + idLoad(); }); diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index b3efd96..2499cda 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -11,7 +11,7 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); router.get("/council/:university_url", ctrl.output.council); router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityID", ctrl.council.getUniversityID); -router.post("/getCardNewsImageUrl", ctrl.council.getImages); +router.post("/getImages", ctrl.council.getImages); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); From 85f10c7b98ce1192f4b76d37b997de22277526a5 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Mon, 26 May 2025 18:56:20 +0000 Subject: [PATCH 19/48] =?UTF-8?q?[FIX]=20=EB=9D=BC=EC=9A=B0=ED=84=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 2 +- src/public/js/council.js | 2 +- src/routes/startRoute.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 64fe315..4c2f913 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -40,7 +40,7 @@ const council = { } }, - getImages: async (req, res) => { + getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); const university = new University(); try { diff --git a/src/public/js/council.js b/src/public/js/council.js index 06aa52b..2e2f3ab 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -170,7 +170,7 @@ function setSwiper() { const universityName = document.querySelector("#universityName"); var Uniname = []; -var university_id; +var current_university_id; var imageUrls = []; // 카드뉴스 이미지 추가 함수 diff --git a/src/routes/startRoute.js b/src/routes/startRoute.js index 2499cda..3a903c4 100644 --- a/src/routes/startRoute.js +++ b/src/routes/startRoute.js @@ -11,7 +11,7 @@ router.get("/showUniversityNameList", ctrl.mainpage.showUniversityNameList); router.get("/council/:university_url", ctrl.output.council); router.post("/getUniversityName", ctrl.council.getUniversityName); router.post("/getUniversityID", ctrl.council.getUniversityID); -router.post("/getImages", ctrl.council.getImages); +router.post("/getCardNewsImageUrl", ctrl.council.getCardNewsImageUrl); router.post("/getUniversityLocation", ctrl.council.getUniversityLocation); From c25ad7b30a94dd144df3ce91a921058e211f975b Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Mon, 26 May 2025 19:35:38 +0000 Subject: [PATCH 20/48] =?UTF-8?q?[FIX]=20getCardNewsImageUrl=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=B4=EB=82=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 7 +++++-- src/public/js/council.js | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 4c2f913..8d563a1 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -33,7 +33,7 @@ const council = { //데이터 수신 const university_id = await receiveUniversityData('RecvStartUniversityID'); console.log("home: university id:", university_id); - return res.json(university_id); + return res.json({university_id}); } catch (err) { console.log("getUniversityID error", err); return res.status(500).json({ error: 'Internal Server Error' }); @@ -42,7 +42,10 @@ const council = { getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); - const university = new University(); + console.log("받은 데이터:", req.body); + return res.json({ result: 1 }); + + const university = new University(); try { //1. url로 id 얻어오기 //2. post-service랑 통신해서 post_img_id, img_url 가져오기 diff --git a/src/public/js/council.js b/src/public/js/council.js index 2e2f3ab..41db754 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -318,6 +318,21 @@ function idLoad() { .then((res) => res.json()) .then(res => { console.log("idLoad univ_id: ", res); + current_university_id = res.university_id; + console.log("current_id: ", current_university_id); //테스트용 로그 + }) + .then(() => { + return fetch(`${apiUrl}/getCardNewsImageUrl`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ university_id: current_university_id }) + }); + }) + .then((res) => res.json()) + .then((res) => { + console.log("getimage: ", res); }); } @@ -332,7 +347,7 @@ function imageLoad() { window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); - imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 + //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); idLoad(); From b7d4221b57e76cec16a71be70fa759920e5701da Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Tue, 27 May 2025 05:14:00 +0900 Subject: [PATCH 21/48] [FIX] getCardNewsImageUrl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rabbitmq 코드로 수정 --- src/controllers/home.ctrl.js | 14 ++++++++++---- src/public/js/council.js | 9 ++------- src/rabbit/rabbitMQ.js | 11 ++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 8d563a1..1c886b6 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -42,10 +42,16 @@ const council = { getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); - console.log("받은 데이터:", req.body); - return res.json({ result: 1 }); - - const university = new University(); + const university_id = req.body.university_id; + await sendUniversityID(university_id.body); + + const post_info = await receiveUniversityData('RecvStartPostInfo'); + console.log("home: post info:", post_info); + return res.json({post_info}); + //return res.json({ result: 1 }); + + // rabbitmq로 바꾸기 전 코드 + const university = new University(); try { //1. url로 id 얻어오기 //2. post-service랑 통신해서 post_img_id, img_url 가져오기 diff --git a/src/public/js/council.js b/src/public/js/council.js index 41db754..9731ad7 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -302,7 +302,7 @@ function nameLoad() { }); } //2. url -> id -function idLoad() { +function imageLoad() { const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl @@ -336,11 +336,6 @@ function idLoad() { }); } -//3. id -> post_id, img_url -function imageLoad() { - -} - //4. url -> location //------------------- @@ -350,7 +345,7 @@ window.addEventListener('DOMContentLoaded', function() { //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - idLoad(); + imageLoad(); }); diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js index dad91ee..d08cf5a 100644 --- a/src/rabbit/rabbitMQ.js +++ b/src/rabbit/rabbitMQ.js @@ -74,10 +74,11 @@ async function receiveUniversityData(queueName) { throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); } -async function sendUniversityID(university_id, sendQueueName) { +//post-service로 university_id 수신 +async function sendUniversityID(university_id) { if (!channel) await connectRabbitMQ(); channel.sendToQueue( - sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 + SendPostInfo, Buffer.from(JSON.stringify({ university_id })), { replyTo: 'RecvStartPostInfo', @@ -85,9 +86,9 @@ async function sendUniversityID(university_id, sendQueueName) { ); } -async function receivePostInfo(queueName) { - if (!channel) await connectRabbitMQ(); -} +// async function receivePostInfo(queueName) { +// if (!channel) await connectRabbitMQ(); +// } module.exports = { sendUniversityURL, From 6c937fe504194b2bbcbc87edce4ad9f2d443a0a5 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 01:14:15 +0900 Subject: [PATCH 22/48] =?UTF-8?q?[FIX]=20=EB=A6=AC=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EB=A0=89=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/apiUrl.js | 10 ++++++++-- src/public/js/council.js | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/public/js/apiUrl.js b/src/public/js/apiUrl.js index 7baa4bc..4d44670 100644 --- a/src/public/js/apiUrl.js +++ b/src/public/js/apiUrl.js @@ -1,2 +1,8 @@ -// config.js -const apiUrl = 'http://34.47.84.123:3001'; +export const apiUrl = 'http://34.47.84.123:3001'; + +// 마이크로서비스별 API 주소 +export const baseUrls = { + post: "http://34.47.84.123:3000", + partner: "http://34.47.84.123:3003", + user: "http://34.47.84.123:3004" +}; \ No newline at end of file diff --git a/src/public/js/council.js b/src/public/js/council.js index 9731ad7..748f7a0 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -1,5 +1,7 @@ import loadKakaoMap from '/js/kakaomapLoader.js'; import apiKeys from './apiKey.js'; +import { apiUrl } from '/js/apiUrl.js'; +import { baseUrls } from 'js/apiUrl.js'; //로그인(로그아웃), 회원가입(마이페이지)버튼 const loginStatusBtn = document.getElementById("loginStatusBtn"); @@ -14,9 +16,10 @@ const navBar=document.getElementById("navbar"); //auth 로그인 정보 가져오기 let userInfo; +const userApiUrl = baseUrls.user; const loadloginData = async () => { - const res = await fetch("/auth/me", { + const res = await fetch(`${userApiUrl}/auth/logout`, { credentials: "include", // 쿠키 포함 }); @@ -417,17 +420,22 @@ function generateDynamicURL(linkId, userschool) { // linkId에 따라 동적 값을 할당하는 로직을 구현합니다. if (linkId === "retailer") { dynamicValue = "retailer/" + userschool; + url = baseUrls.partner; } else if (linkId === "partner") { dynamicValue = "partner/" + userschool; + url = baseUrls.partner; } else if (linkId === "more_news") { dynamicValue = "showPostListAll/" + userschool; + url = baseUrls.post; } else if (linkId === "more_retailer") { dynamicValue = "retailer/" + userschool; + url = baseUrls.partner; } else if (linkId === "news") { dynamicValue = "showPostListAll/" + userschool; + url = baseUrls.post; } - return `${apiUrl}/` + dynamicValue; + return `${url}/` + dynamicValue; } // 새로운 url로 업데이트 From 07a29e082cbc04bdd7eaa563a23ca1ca214bc910 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Tue, 27 May 2025 18:56:38 +0000 Subject: [PATCH 23/48] Revert "[FIX] getCardNewsImageUrl" This reverts commit b7d4221b57e76cec16a71be70fa759920e5701da. --- src/controllers/home.ctrl.js | 14 ++++---------- src/public/js/council.js | 9 +++++++-- src/rabbit/rabbitMQ.js | 11 +++++------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 1c886b6..8d563a1 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -42,16 +42,10 @@ const council = { getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); - const university_id = req.body.university_id; - await sendUniversityID(university_id.body); - - const post_info = await receiveUniversityData('RecvStartPostInfo'); - console.log("home: post info:", post_info); - return res.json({post_info}); - //return res.json({ result: 1 }); - - // rabbitmq로 바꾸기 전 코드 - const university = new University(); + console.log("받은 데이터:", req.body); + return res.json({ result: 1 }); + + const university = new University(); try { //1. url로 id 얻어오기 //2. post-service랑 통신해서 post_img_id, img_url 가져오기 diff --git a/src/public/js/council.js b/src/public/js/council.js index 748f7a0..3b81267 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -305,7 +305,7 @@ function nameLoad() { }); } //2. url -> id -function imageLoad() { +function idLoad() { const universityUrl = getUniversityUrl(); const req = { university_url: universityUrl @@ -339,6 +339,11 @@ function imageLoad() { }); } +//3. id -> post_id, img_url +function imageLoad() { + +} + //4. url -> location //------------------- @@ -348,7 +353,7 @@ window.addEventListener('DOMContentLoaded', function() { //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - imageLoad(); + idLoad(); }); diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js index d08cf5a..dad91ee 100644 --- a/src/rabbit/rabbitMQ.js +++ b/src/rabbit/rabbitMQ.js @@ -74,11 +74,10 @@ async function receiveUniversityData(queueName) { throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); } -//post-service로 university_id 수신 -async function sendUniversityID(university_id) { +async function sendUniversityID(university_id, sendQueueName) { if (!channel) await connectRabbitMQ(); channel.sendToQueue( - SendPostInfo, + sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 Buffer.from(JSON.stringify({ university_id })), { replyTo: 'RecvStartPostInfo', @@ -86,9 +85,9 @@ async function sendUniversityID(university_id) { ); } -// async function receivePostInfo(queueName) { -// if (!channel) await connectRabbitMQ(); -// } +async function receivePostInfo(queueName) { + if (!channel) await connectRabbitMQ(); +} module.exports = { sendUniversityURL, From 0b328145ed3f6d9d7515d928c1db09d27cd2df45 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Tue, 27 May 2025 19:10:29 +0000 Subject: [PATCH 24/48] =?UTF-8?q?[FIX]=20apiUrl=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/apiUrl.js | 2 +- src/public/js/council.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/js/apiUrl.js b/src/public/js/apiUrl.js index 4d44670..4ecaeb6 100644 --- a/src/public/js/apiUrl.js +++ b/src/public/js/apiUrl.js @@ -5,4 +5,4 @@ export const baseUrls = { post: "http://34.47.84.123:3000", partner: "http://34.47.84.123:3003", user: "http://34.47.84.123:3004" -}; \ No newline at end of file +}; diff --git a/src/public/js/council.js b/src/public/js/council.js index 3b81267..b524212 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -1,7 +1,7 @@ import loadKakaoMap from '/js/kakaomapLoader.js'; import apiKeys from './apiKey.js'; import { apiUrl } from '/js/apiUrl.js'; -import { baseUrls } from 'js/apiUrl.js'; +import { baseUrls } from './apiUrl.js'; //로그인(로그아웃), 회원가입(마이페이지)버튼 const loginStatusBtn = document.getElementById("loginStatusBtn"); From 705ac620d6f8ef3ea7bc57a9765c2c9af75552b3 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Wed, 28 May 2025 10:42:31 +0000 Subject: [PATCH 25/48] =?UTF-8?q?[FIX]=20rabbitmq=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 9 +++++++-- src/rabbit/rabbitMQ.js | 17 +++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 8d563a1..39422b2 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -42,8 +42,13 @@ const council = { getCardNewsImageUrl: async (req, res) => { console.log("home.ctrl의 getImages"); - console.log("받은 데이터:", req.body); - return res.json({ result: 1 }); + const university_id = req.body.university_id; + await sendUniversityID(university_id, 'SendPostList'); + + const post_info = await receiveUniversityData('RecvPostList'); + console.log("home: post info:", post_info); + return res.json({post_info}); + //return res.json({ result: 1 }); const university = new University(); try { diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js index dad91ee..b27e1d6 100644 --- a/src/rabbit/rabbitMQ.js +++ b/src/rabbit/rabbitMQ.js @@ -4,13 +4,13 @@ const RECV_QUEUES = [ 'RecvStartUniversityName', 'RecvStartUniversityID', 'RecvStartUniversityLocation', - 'RecvStartPostInfo' + 'RecvPostList' ]; const SEND_QUEUES = [ 'SendUniversityName', 'SendUniversityID', 'SendUniversityLocation', - 'SendPostInfo' + 'SendPostList' ]; let channel; @@ -74,23 +74,24 @@ async function receiveUniversityData(queueName) { throw new Error(`${queueName} 큐에서 메시지를 받지 못했습니다.`); } +//post-service로 university_id 수신 async function sendUniversityID(university_id, sendQueueName) { if (!channel) await connectRabbitMQ(); + let recvQueueName = 'RecvPostList'; + + console.log('rabbit의 sendUniversityID 실행'); channel.sendToQueue( sendQueueName, // 올바르게 인자로 받은 큐 이름 사용 - Buffer.from(JSON.stringify({ university_id })), + Buffer.from(JSON.stringify({university_id})), { - replyTo: 'RecvStartPostInfo', + replyTo: recvQueueName, } ); } -async function receivePostInfo(queueName) { - if (!channel) await connectRabbitMQ(); -} - module.exports = { sendUniversityURL, sendUniversityID, receiveUniversityData }; + From 0a11e46b3c9003e5647e287a031c7e326d61a66c Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 19:51:27 +0900 Subject: [PATCH 26/48] =?UTF-8?q?[FIX]=20url=20=EB=B3=80=EC=88=98=EB=AA=85?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index b524212..a3e69ba 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -72,7 +72,7 @@ function getUniversityUrl() { console.log("universityUrl: ", universityUrl); return universityUrl; } -var university_url = getUniversityUrl(); +var current_university_url = getUniversityUrl(); function setCenter(map,latitude,longitude){ // 이동할 위도 경도 위치를 생성합니다 @@ -224,7 +224,7 @@ async function fetchImageUrls(imageData) { function imagesLoadTest() { console.log("imagesLoadTest 시작"); //테스트용 로그 - const universityUrl = getUniversityUrl(); + const universityUrl = current_university_url; const req = { university_url: universityUrl }; @@ -244,7 +244,7 @@ function imagesLoadTest() { } function councilLoad() { //-> nameLoad - const universityUrl = getUniversityUrl(); + const universityUrl = current_university_url; const req = { university_url: universityUrl }; @@ -285,7 +285,7 @@ function councilLoad() { //-> nameLoad //------------------- //1. url -> name function nameLoad() { - const universityUrl = getUniversityUrl(); + const universityUrl = current_university_url; const req = { university_url: universityUrl }; @@ -306,7 +306,7 @@ function nameLoad() { } //2. url -> id function idLoad() { - const universityUrl = getUniversityUrl(); + const universityUrl = current_university_url; const req = { university_url: universityUrl }; From 9222df51505b46117e03e96cba36ac6575fd7dbd Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 20:19:24 +0900 Subject: [PATCH 27/48] =?UTF-8?q?[FIX]=20=EB=A6=AC=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EB=A0=89=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index a3e69ba..691b08c 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -339,11 +339,17 @@ function idLoad() { }); } -//3. id -> post_id, img_url -function imageLoad() { - +const directIdData = async () => { + console.log('directIdload 실행'); + const url = `${userApiUrl}/university/university-id`; + const res = await fetch(url); + const data = await res.json(); + console.log("directIdData: ", data); } +//3. id -> post_id, img_url + + //4. url -> location //------------------- @@ -354,6 +360,7 @@ window.addEventListener('DOMContentLoaded', function() { //councilLoad(); nameLoad(); idLoad(); + directIdData(); }); @@ -451,6 +458,8 @@ async function updateDynamicLinks() { return; } + //var userschool = current_university_url; + var link1 = document.getElementById("main_retailer"); var link2 = document.getElementById("partner"); var link3 = document.getElementById("news"); From d793a52e0ce54ad57279cb21dad25a7c37117993 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 20:28:37 +0900 Subject: [PATCH 28/48] =?UTF-8?q?[FIX]=20=EB=A6=AC=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EB=A0=89=ED=8A=B8=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 691b08c..54f5ce7 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -428,6 +428,7 @@ function getDynamicValueFromURL() { // 새로운 url 만들기 function generateDynamicURL(linkId, userschool) { var dynamicValue; + var url; // linkId에 따라 동적 값을 할당하는 로직을 구현합니다. if (linkId === "retailer") { @@ -458,8 +459,6 @@ async function updateDynamicLinks() { return; } - //var userschool = current_university_url; - var link1 = document.getElementById("main_retailer"); var link2 = document.getElementById("partner"); var link3 = document.getElementById("news"); From 3a938d1f8bbec787c69c17265897e74527169c93 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Wed, 28 May 2025 13:21:45 +0000 Subject: [PATCH 29/48] =?UTF-8?q?[fix]=20=EB=A7=81=ED=81=AC=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/public/js/council.js b/src/public/js/council.js index 691b08c..ea8e8b0 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -428,6 +428,7 @@ function getDynamicValueFromURL() { // 새로운 url 만들기 function generateDynamicURL(linkId, userschool) { var dynamicValue; + var url; // linkId에 따라 동적 값을 할당하는 로직을 구현합니다. if (linkId === "retailer") { From 7c7b489b622ff26ef1598669e39322897383cb6b Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 22:26:20 +0900 Subject: [PATCH 30/48] [fix] universityUrl --- src/public/js/council.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 54f5ce7..ec29a70 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -69,8 +69,8 @@ function getUniversityUrl() { // 경로에서 universityUrl 값을 추출 const pathParts = path.split('/'); const universityUrl = pathParts[pathParts.length - 1]; - console.log("universityUrl: ", universityUrl); - return universityUrl; + console.log("universityUrl: ", universityUrl.universityUrl); + return universityUrl.universityUrl; } var current_university_url = getUniversityUrl(); From 5fc114b7e1bb19ea428f09e495b4e884eff91fb6 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Wed, 28 May 2025 22:32:34 +0900 Subject: [PATCH 31/48] =?UTF-8?q?[fix]=20getUniversityUrl=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index ec29a70..54f5ce7 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -69,8 +69,8 @@ function getUniversityUrl() { // 경로에서 universityUrl 값을 추출 const pathParts = path.split('/'); const universityUrl = pathParts[pathParts.length - 1]; - console.log("universityUrl: ", universityUrl.universityUrl); - return universityUrl.universityUrl; + console.log("universityUrl: ", universityUrl); + return universityUrl; } var current_university_url = getUniversityUrl(); From ab039390a8207af794cb6f973c528003a8b34051 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Wed, 28 May 2025 14:14:00 +0000 Subject: [PATCH 32/48] =?UTF-8?q?[FIX]=20getUniversityUrl=20=EA=B3=A0?= =?UTF-8?q?=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index ec29a70..99a99e1 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -61,16 +61,27 @@ window.addEventListener('DOMContentLoaded', function () { // } +// university_url 값을 받아오는 함수 +// function getUniversityUrl() { +// // 현재 페이지의 URL에서 경로(pathname) 부분을 추출 +// const path = window.location.pathname; + +// // 경로에서 universityUrl 값을 추출 +// const pathParts = path.split('/'); +// const universityUrl = pathParts[pathParts.length - 1]; +// console.log("universityUrl: ", universityUrl); +// return universityUrl; +// } +// var current_university_url = getUniversityUrl(); + +//const url = new URL(window.location.href); +// const universityUrl = url.pathname.split('/').pop(); +// return universityUrl; // university_url 값을 받아오는 함수 function getUniversityUrl() { - // 현재 페이지의 URL에서 경로(pathname) 부분을 추출 - const path = window.location.pathname; - - // 경로에서 universityUrl 값을 추출 - const pathParts = path.split('/'); - const universityUrl = pathParts[pathParts.length - 1]; - console.log("universityUrl: ", universityUrl.universityUrl); - return universityUrl.universityUrl; + const url = new URL(window.location.href); + const universityUrl = url.pathname.split('/').pop(); + return universityUrl; } var current_university_url = getUniversityUrl(); @@ -355,12 +366,12 @@ const directIdData = async () => { window.addEventListener('DOMContentLoaded', function() { setSwiper(); - updateDynamicLinks(); + //updateDynamicLinks(); //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - idLoad(); - directIdData(); + //idLoad(); + //directIdData(); }); From 9b9c5db194d1d9b0a74d96d652d213f0af9afaa8 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Wed, 28 May 2025 15:18:24 +0000 Subject: [PATCH 33/48] =?UTF-8?q?[FEAT]=20post=EB=9E=91=20=ED=86=B5?= =?UTF-8?q?=EC=8B=A0=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 2 +- src/public/js/council.js | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 39422b2..0ad57d1 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -47,7 +47,7 @@ const council = { const post_info = await receiveUniversityData('RecvPostList'); console.log("home: post info:", post_info); - return res.json({post_info}); + return post_info; //return res.json({ result: 1 }); const university = new University(); diff --git a/src/public/js/council.js b/src/public/js/council.js index 54f5ce7..37e9a1c 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -62,14 +62,25 @@ window.addEventListener('DOMContentLoaded', function () { // university_url 값을 받아오는 함수 -function getUniversityUrl() { - // 현재 페이지의 URL에서 경로(pathname) 부분을 추출 - const path = window.location.pathname; +// function getUniversityUrl() { +// // 현재 페이지의 URL에서 경로(pathname) 부분을 추출 +// const path = window.location.pathname; + +// // 경로에서 universityUrl 값을 추출 +// const pathParts = path.split('/'); +// const universityUrl = pathParts[pathParts.length - 1]; +// console.log("universityUrl: ", universityUrl); +// return universityUrl; +// } +// var current_university_url = getUniversityUrl(); - // 경로에서 universityUrl 값을 추출 - const pathParts = path.split('/'); - const universityUrl = pathParts[pathParts.length - 1]; - console.log("universityUrl: ", universityUrl); +//const url = new URL(window.location.href); +// const universityUrl = url.pathname.split('/').pop(); +// return universityUrl; +// university_url 값을 받아오는 함수 +function getUniversityUrl() { + const url = new URL(window.location.href); + const universityUrl = url.pathname.split('/').pop(); return universityUrl; } var current_university_url = getUniversityUrl(); @@ -333,7 +344,6 @@ function idLoad() { body: JSON.stringify({ university_id: current_university_id }) }); }) - .then((res) => res.json()) .then((res) => { console.log("getimage: ", res); }); @@ -355,12 +365,12 @@ const directIdData = async () => { window.addEventListener('DOMContentLoaded', function() { setSwiper(); - updateDynamicLinks(); + //updateDynamicLinks(); //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); idLoad(); - directIdData(); + //directIdData(); }); From e067f073edf6c6aa8d2c994db9dbcb621156bf01 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Wed, 28 May 2025 15:37:25 +0000 Subject: [PATCH 34/48] =?UTF-8?q?[fix]=20post=20=ED=86=B5=EC=8B=A0?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EB=A8=B8=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 2 +- src/public/js/council.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 39422b2..0ad57d1 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -47,7 +47,7 @@ const council = { const post_info = await receiveUniversityData('RecvPostList'); console.log("home: post info:", post_info); - return res.json({post_info}); + return post_info; //return res.json({ result: 1 }); const university = new University(); diff --git a/src/public/js/council.js b/src/public/js/council.js index 99a99e1..37e9a1c 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -344,7 +344,6 @@ function idLoad() { body: JSON.stringify({ university_id: current_university_id }) }); }) - .then((res) => res.json()) .then((res) => { console.log("getimage: ", res); }); @@ -370,7 +369,7 @@ window.addEventListener('DOMContentLoaded', function() { //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - //idLoad(); + idLoad(); //directIdData(); }); From ca03fefa504bcea721922c7ae5b6cd9f102e59a5 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Thu, 29 May 2025 07:07:55 +0000 Subject: [PATCH 35/48] =?UTF-8?q?[fix]=20post=EA=B0=84=EC=A0=91=20?= =?UTF-8?q?=ED=86=B5=EC=8B=A0=20=EC=A7=84=EC=A7=9C=20=EC=84=B1=EA=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 11 +++++++---- src/public/js/council.js | 17 ++++++++++++++++- src/rabbit/rabbitMQ.js | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 0ad57d1..ff92f2f 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -29,11 +29,14 @@ const council = { console.log("home.ctrl의 getUniversityID "); const university_url = req.body.university_url; await sendUniversityURL(university_url, 'SendUniversityID'); - - //데이터 수신 const university_id = await receiveUniversityData('RecvStartUniversityID'); - console.log("home: university id:", university_id); - return res.json({university_id}); + console.log("home: university id:", university_id); + + await sendUniversityID(university_id, 'SendPostList'); + const post_info = await receiveUniversityData('RecvPostList'); + console.log('home post_info: ', post_info); + + return res.json({post_info}); } catch (err) { console.log("getUniversityID error", err); return res.status(500).json({ error: 'Internal Server Error' }); diff --git a/src/public/js/council.js b/src/public/js/council.js index 37e9a1c..48845b7 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -349,6 +349,21 @@ function idLoad() { }); } +function idLoad2() { + const universityUrl = current_university_url; + const req = { + university_url: universityUrl + }; + + fetch(`${apiUrl}/getUniversityID`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) +} + const directIdData = async () => { console.log('directIdload 실행'); const url = `${userApiUrl}/university/university-id`; @@ -369,7 +384,7 @@ window.addEventListener('DOMContentLoaded', function() { //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - idLoad(); + idLoad2(); //directIdData(); }); diff --git a/src/rabbit/rabbitMQ.js b/src/rabbit/rabbitMQ.js index b27e1d6..2697a8a 100644 --- a/src/rabbit/rabbitMQ.js +++ b/src/rabbit/rabbitMQ.js @@ -76,6 +76,8 @@ async function receiveUniversityData(queueName) { //post-service로 university_id 수신 async function sendUniversityID(university_id, sendQueueName) { + await channel.assertQueue(sendQueueName, { durable: false }); + if (!channel) await connectRabbitMQ(); let recvQueueName = 'RecvPostList'; From 56b4a585a14f5e12e7cefd5ed46d7c921b8efb89 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 17:10:09 +0900 Subject: [PATCH 36/48] =?UTF-8?q?[TEST]=20getimageurl=20=EB=A6=AC=ED=84=B4?= =?UTF-8?q?=20=EA=B2=B0=EA=B3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 6 ++++-- src/public/js/council.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index ff92f2f..31a8343 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -34,9 +34,11 @@ const council = { await sendUniversityID(university_id, 'SendPostList'); const post_info = await receiveUniversityData('RecvPostList'); - console.log('home post_info: ', post_info); + console.log('home post_info: ', post_info.post_info); + const result = post_info.post_info.post_info; + console.log('home result: ', result); - return res.json({post_info}); + return res.json({result}); } catch (err) { console.log("getUniversityID error", err); return res.status(500).json({ error: 'Internal Server Error' }); diff --git a/src/public/js/council.js b/src/public/js/council.js index 48845b7..f72013b 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -202,9 +202,9 @@ async function fetchImageUrls(imageData) { for (let i = 0; i <= imageData.length - 1; i++) { const currentData = imageData[i]; // 현재 이미지 데이터 // 이미지 데이터의 형태가 객체인지 확인 - if (currentData && currentData.image_url) { + if (currentData && currentData.img_url) { //console.log(imageUrls.length); - imageUrls.push(currentData.image_url); // 이미지를 배열에 추가 + imageUrls.push(currentData.img_url); // 이미지를 배열에 추가 const imgContainer = document.createElement('div'); imgContainer.classList.add('swiper-slide'); @@ -215,7 +215,7 @@ async function fetchImageUrls(imageData) { const imgElement = document.createElement('img'); imgElement.classList.add('news'); - imgElement.src = currentData.image_url; + imgElement.src = currentData.img_url; imgElement.alt = 'no_image' + imageUrls.length; imgLink.appendChild(imgElement); @@ -362,6 +362,13 @@ function idLoad2() { }, body: JSON.stringify(req), }) + .then((res) => res.json()) + .then((data) => { + console.log("getimage: ", data); + console.log("idLoad2 test1: ", data.result); + console.log("idLoad2 test2: ", data.result[0].img_url); + fetchImageUrls(data.result); + }); } const directIdData = async () => { From 37ac37cc049c70d390f560a4ed03e9d9e829e78c Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Thu, 29 May 2025 08:24:22 +0000 Subject: [PATCH 37/48] =?UTF-8?q?[FIX]=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=9D=84=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 31a8343..5db89c5 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -35,7 +35,7 @@ const council = { await sendUniversityID(university_id, 'SendPostList'); const post_info = await receiveUniversityData('RecvPostList'); console.log('home post_info: ', post_info.post_info); - const result = post_info.post_info.post_info; + const result = post_info.post_info; console.log('home result: ', result); return res.json({result}); From 2f3d6e326dc2579ad263b4b47a1240d24fbc60cc Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 17:26:23 +0900 Subject: [PATCH 38/48] =?UTF-8?q?[FIX]=20=ED=95=A8=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit idLoad2 -> imageLoad --- src/public/js/council.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index f72013b..682e0da 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -349,7 +349,7 @@ function idLoad() { }); } -function idLoad2() { +function imageLoad() { const universityUrl = current_university_url; const req = { university_url: universityUrl @@ -365,8 +365,8 @@ function idLoad2() { .then((res) => res.json()) .then((data) => { console.log("getimage: ", data); - console.log("idLoad2 test1: ", data.result); - console.log("idLoad2 test2: ", data.result[0].img_url); + console.log("imageLoad test1: ", data.result); + console.log("imageLoad test2: ", data.result[0].img_url); fetchImageUrls(data.result); }); } @@ -391,7 +391,7 @@ window.addEventListener('DOMContentLoaded', function() { //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 //councilLoad(); nameLoad(); - idLoad2(); + imageLoad(); //directIdData(); }); From 861a73c95c8d90910e82d9d1196d0b362a68f2ec Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 17:31:32 +0900 Subject: [PATCH 39/48] =?UTF-8?q?[FIX]=20=EC=95=88=EC=93=B0=EB=8A=94=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 113 +-------------------------------------- 1 file changed, 1 insertion(+), 112 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 682e0da..8cfbbbc 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -233,67 +233,6 @@ async function fetchImageUrls(imageData) { } } -function imagesLoadTest() { - console.log("imagesLoadTest 시작"); //테스트용 로그 - const universityUrl = current_university_url; - const req = { - university_url: universityUrl - }; - - console.log("apiUrl: ", `${apiUrl}`); //테스트용 로그 - fetch(`${apiUrl}/getImages`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(req), - }) - .then((res) => res.json()) - .then((imageData) => { - fetchImageUrls(imageData); - }) -} - -function councilLoad() { //-> nameLoad - const universityUrl = current_university_url; - const req = { - university_url: universityUrl - }; - - fetch(`${apiUrl}/getUniversityName`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(req), - }) - .then((res) => res.json()) - .then(res => { - console.log("councilLoad universityInfo: ", res); - Uniname.push(res.university_name); - universityName.innerHTML = Uniname[0]; - // console.log("council의 Uniname[0]: ", Uniname[0]); //테스트용 로그 - // console.log("council의 universityName: ", universityName.innerHTML); //테스트용 로그 - }); - // .then(() => { - // return fetch(`${apiUrl}/getCardNewsImageUrl`, { - // method: "POST", - // headers: { - // "Content-Type": "application/json", - // }, - // body: JSON.stringify(req), - // }); - // }) - // .then((res) => res.json()) - // .then((imageData) => { // 이미지 데이터를 변수 imageData로 받아옴 - // fetchImageUrls(imageData); // 이미지 데이터를 fetchImageUrls 함수의 인자로 전달 - // }) - // .catch(error => { - // console.error('Error:', error); - // }); -} - -//------------------- //1. url -> name function nameLoad() { const universityUrl = current_university_url; @@ -315,40 +254,8 @@ function nameLoad() { universityName.innerHTML = Uniname[0]; }); } -//2. url -> id -function idLoad() { - const universityUrl = current_university_url; - const req = { - university_url: universityUrl - }; - - fetch(`${apiUrl}/getUniversityID`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(req), - }) - .then((res) => res.json()) - .then(res => { - console.log("idLoad univ_id: ", res); - current_university_id = res.university_id; - console.log("current_id: ", current_university_id); //테스트용 로그 - }) - .then(() => { - return fetch(`${apiUrl}/getCardNewsImageUrl`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ university_id: current_university_id }) - }); - }) - .then((res) => { - console.log("getimage: ", res); - }); -} +//url -> id -> image function imageLoad() { const universityUrl = current_university_url; const req = { @@ -371,28 +278,10 @@ function imageLoad() { }); } -const directIdData = async () => { - console.log('directIdload 실행'); - const url = `${userApiUrl}/university/university-id`; - const res = await fetch(url); - const data = await res.json(); - console.log("directIdData: ", data); -} - -//3. id -> post_id, img_url - - -//4. url -> location -//------------------- - window.addEventListener('DOMContentLoaded', function() { setSwiper(); - //updateDynamicLinks(); - //imagesLoadTest(); //포스트 이미지를 가져오는 함수, 임시라서 나중에 councilLoad랑 합치기 - //councilLoad(); nameLoad(); imageLoad(); - //directIdData(); }); From 435aab22d855e68e0051f0cb1af75b23f3209db2 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 17:40:35 +0900 Subject: [PATCH 40/48] =?UTF-8?q?[FIX]=20=EB=A6=AC=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EB=A0=89=ED=8A=B8=20=EB=B3=80=EC=88=98=EB=AA=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 8cfbbbc..66b2888 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -280,6 +280,7 @@ function imageLoad() { window.addEventListener('DOMContentLoaded', function() { setSwiper(); + updateDynamicLinks(); nameLoad(); imageLoad(); }); @@ -349,27 +350,27 @@ function getDynamicValueFromURL() { // 새로운 url 만들기 function generateDynamicURL(linkId, userschool) { var dynamicValue; - var url; + var next_url; // linkId에 따라 동적 값을 할당하는 로직을 구현합니다. if (linkId === "retailer") { dynamicValue = "retailer/" + userschool; - url = baseUrls.partner; + next_url = baseUrls.partner; } else if (linkId === "partner") { dynamicValue = "partner/" + userschool; - url = baseUrls.partner; + next_url = baseUrls.partner; } else if (linkId === "more_news") { dynamicValue = "showPostListAll/" + userschool; - url = baseUrls.post; + next_url = baseUrls.post; } else if (linkId === "more_retailer") { dynamicValue = "retailer/" + userschool; - url = baseUrls.partner; + next_url = baseUrls.partner; } else if (linkId === "news") { dynamicValue = "showPostListAll/" + userschool; - url = baseUrls.post; + next_url = baseUrls.post; } - return `${url}/` + dynamicValue; + return `${next_url}/` + dynamicValue; } // 새로운 url로 업데이트 From e67539043419fff26d30c2db267e58413428623b Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 17:59:09 +0900 Subject: [PATCH 41/48] =?UTF-8?q?[FIX]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 59 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 66b2888..844da49 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -18,18 +18,63 @@ const navBar=document.getElementById("navbar"); let userInfo; const userApiUrl = baseUrls.user; +// 로그아웃 처리 함수 +const handleLogout = async () => { + try { + const res = await fetch(`${userApiUrl}/auth/logout`, { + method: "POST", + credentials: "include" + }); + + if (res.ok) { + // 로그아웃 성공 시 페이지 새로고침 + window.location.reload(); // 또는 window.location.href = "/"; + } else { + const data = await res.json(); + alert(data.message || "로그아웃에 실패했습니다."); + } + } catch (err) { + console.error("로그아웃 요청 중 오류 발생:", err); + alert("서버 오류로 로그아웃에 실패했습니다."); + } +}; + +// 작성자 회원 정보 불러오기 const loadloginData = async () => { - const res = await fetch(`${userApiUrl}/auth/logout`, { + const res = await fetch(`${userApiUrl}/auth/me`, { credentials: "include", // 쿠키 포함 }); - - userInfo = await res.json(); // 유저 정보가 저장되는 변수 + if (res.ok == true){ + loginStatusBtn.innerText = "로그아웃" + loginStatusBtn.removeAttribute("href"); // 기본 링크 제거 + loginStatusBtn.addEventListener("click", (e) => { + e.preventDefault(); // 링크 동작 막기 + handleLogout(); // 로그아웃 요청 + }); + signUpBtn.setAttribute("href", `${userApiUrl}/mypage`); + signUpBtn.innerText = "마이페이지" + } else { + loginStatusBtn.setAttribute("href", `${userApiUrl}/login`); + loginStatusBtn.innerText = "로그인" + signUpBtn.setAttribute("href", `${userApiUrl}/signup/agreement`); + signUpBtn.innerText = "회원가입" + } + const data = await res.json(); + userInfo = data; }; +// const loadloginData = async () => { +// const res = await fetch(`${userApiUrl}/auth/logout`, { +// credentials: "include", // 쿠키 포함 +// }); + +// userInfo = await res.json(); // 유저 정보가 저장되는 변수 +// }; + // 페이지 로드 후 로그인 정보 획득 -window.addEventListener('DOMContentLoaded', function () { - loadloginData(); -}); +// window.addEventListener('DOMContentLoaded', function () { +// loadloginData(); +// }); //회원로그인 정보 불러오기 // const loadloginData = () => { @@ -77,6 +122,7 @@ window.addEventListener('DOMContentLoaded', function () { //const url = new URL(window.location.href); // const universityUrl = url.pathname.split('/').pop(); // return universityUrl; + // university_url 값을 받아오는 함수 function getUniversityUrl() { const url = new URL(window.location.href); @@ -281,6 +327,7 @@ function imageLoad() { window.addEventListener('DOMContentLoaded', function() { setSwiper(); updateDynamicLinks(); + loadloginData(); nameLoad(); imageLoad(); }); From 7e0abbd29733ac7b50f1808c3bbae57ef4691db3 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 18:35:51 +0900 Subject: [PATCH 42/48] =?UTF-8?q?[FIX]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/apiUrl.js | 1 + src/public/js/council.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/public/js/apiUrl.js b/src/public/js/apiUrl.js index 4ecaeb6..7734789 100644 --- a/src/public/js/apiUrl.js +++ b/src/public/js/apiUrl.js @@ -3,6 +3,7 @@ export const apiUrl = 'http://34.47.84.123:3001'; // 마이크로서비스별 API 주소 export const baseUrls = { post: "http://34.47.84.123:3000", + postReaction: "http://34.47.84.123:3002", partner: "http://34.47.84.123:3003", user: "http://34.47.84.123:3004" }; diff --git a/src/public/js/council.js b/src/public/js/council.js index 844da49..ade9ad2 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -17,6 +17,7 @@ const navBar=document.getElementById("navbar"); //auth 로그인 정보 가져오기 let userInfo; const userApiUrl = baseUrls.user; +const postReactionApiUrl = baseUrls.postReaction; // 로그아웃 처리 함수 const handleLogout = async () => { @@ -51,12 +52,12 @@ const loadloginData = async () => { e.preventDefault(); // 링크 동작 막기 handleLogout(); // 로그아웃 요청 }); - signUpBtn.setAttribute("href", `${userApiUrl}/mypage`); + signUpBtn.setAttribute("href", `${postReactionApiUrl}/mypage`); signUpBtn.innerText = "마이페이지" } else { - loginStatusBtn.setAttribute("href", `${userApiUrl}/login`); + loginStatusBtn.setAttribute("href", `${userApiUrl}/auth/login`); loginStatusBtn.innerText = "로그인" - signUpBtn.setAttribute("href", `${userApiUrl}/signup/agreement`); + signUpBtn.setAttribute("href", `${userApiUrl}/user/agreement`); signUpBtn.innerText = "회원가입" } const data = await res.json(); From 78b3a7b403f9506728eb0a521a284d390da6b502 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 18:45:47 +0900 Subject: [PATCH 43/48] =?UTF-8?q?[FEAT]=20mainpage=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/mainpage.js | 146 +++++++++++++++++++++++++------------- 1 file changed, 98 insertions(+), 48 deletions(-) diff --git a/src/public/js/mainpage.js b/src/public/js/mainpage.js index 8c20821..6bc29f6 100644 --- a/src/public/js/mainpage.js +++ b/src/public/js/mainpage.js @@ -9,39 +9,88 @@ const navBar=document.getElementById("navbar-brand"); let universitySearchList = []; -console.log("mainpage.js 시작"); -const loadData = async () => { - console.log("loadData 실행"); - const url = `${apiUrl}/showUniversityNameList`; - console.log(url, "\n"); - try { - const res = await fetch(url); - const data = await res.json(); - console.log(data); - - if (data.success === true) { - console.log("data.success!\n"); - searchUniversityName(data.result); // 리스트 저장 - console.log("universitySearchList: \n"); - console.log(universitySearchList); - } else { - ul.innerHTML = "
  • 서버 오류로 점검 중입니다. 잠시 후 이용해주세요.
  • "; - } - } catch (err) { - console.error("데이터 로드 중 에러 발생:", err); - ul.innerHTML = "
  • 데이터 로드 실패
  • "; +//auth 로그인 정보 가져오기 +let userInfo; +const userApiUrl = baseUrls.user; +const postReactionApiUrl = baseUrls.postReaction; + +// 로그아웃 처리 함수 +const handleLogout = async () => { + try { + const res = await fetch(`${userApiUrl}/auth/logout`, { + method: "POST", + credentials: "include" + }); + + if (res.ok) { + // 로그아웃 성공 시 페이지 새로고침 + window.location.reload(); // 또는 window.location.href = "/"; + } else { + const data = await res.json(); + alert(data.message || "로그아웃에 실패했습니다."); } + } catch (err) { + console.error("로그아웃 요청 중 오류 발생:", err); + alert("서버 오류로 로그아웃에 실패했습니다."); + } }; -const searchUniversityName = (suggestArr) => { - ul.innerHTML = ""; - suggestArr.forEach((el, idx) => { - // el : {universityname : "성신여자대학교"} - universitySearchList.push(el); - //console.log(el.university_name); - } - ) -} +// 작성자 회원 정보 불러오기 +const loadloginData = async () => { + const res = await fetch(`${userApiUrl}/auth/me`, { + credentials: "include", // 쿠키 포함 + }); + if (res.ok == true){ + loginStatusBtn.innerText = "로그아웃" + loginStatusBtn.removeAttribute("href"); // 기본 링크 제거 + loginStatusBtn.addEventListener("click", (e) => { + e.preventDefault(); // 링크 동작 막기 + handleLogout(); // 로그아웃 요청 + }); + signUpBtn.setAttribute("href", `${postReactionApiUrl}/mypage`); + signUpBtn.innerText = "마이페이지" + } else { + loginStatusBtn.setAttribute("href", `${userApiUrl}/auth/login`); + loginStatusBtn.innerText = "로그인" + signUpBtn.setAttribute("href", `${userApiUrl}/user/agreement`); + signUpBtn.innerText = "회원가입" + } + const data = await res.json(); + userInfo = data; +}; + +// const loadData = async () => { +// console.log("loadData 실행"); +// const url = `${apiUrl}/showUniversityNameList`; +// console.log(url, "\n"); +// try { +// const res = await fetch(url); +// const data = await res.json(); +// console.log(data); + +// if (data.success === true) { +// console.log("data.success!\n"); +// searchUniversityName(data.result); // 리스트 저장 +// console.log("universitySearchList: \n"); +// console.log(universitySearchList); +// } else { +// ul.innerHTML = "
  • 서버 오류로 점검 중입니다. 잠시 후 이용해주세요.
  • "; +// } +// } catch (err) { +// console.error("데이터 로드 중 에러 발생:", err); +// ul.innerHTML = "
  • 데이터 로드 실패
  • "; +// } +// }; + +// const searchUniversityName = (suggestArr) => { +// ul.innerHTML = ""; +// suggestArr.forEach((el, idx) => { +// // el : {universityname : "성신여자대학교"} +// universitySearchList.push(el); +// //console.log(el.university_name); +// } +// ) +// } // const loadloginData = async() => { // console.log("loadloginData 실행\n"); @@ -59,29 +108,30 @@ const searchUniversityName = (suggestArr) => { // } -const setLoginHeader=(res)=>{ - console.log("setLoginHeader 실행\n"); - navBar.setAttribute("href", `${apiUrl}`); - if(res.loginStatus==true){ - loginStatusBtn.setAttribute("href", `${apiUrl}/logout`); - loginStatusBtn.innerText="로그아웃" - signUpBtn.setAttribute("href", `${apiUrl}/mypage`); - signUpBtn.innerText="마이페이지" - } - else{ - loginStatusBtn.setAttribute("href", `${apiUrl}/login`); - loginStatusBtn.innerText="로그인" - signUpBtn.setAttribute("href", `${apiUrl}/signup/agreement`); - signUpBtn.innerText="회원가입" - } +// const setLoginHeader=(res)=>{ +// console.log("setLoginHeader 실행\n"); +// navBar.setAttribute("href", `${apiUrl}`); +// if(res.loginStatus==true){ +// loginStatusBtn.setAttribute("href", `${apiUrl}/logout`); +// loginStatusBtn.innerText="로그아웃" +// signUpBtn.setAttribute("href", `${apiUrl}/mypage`); +// signUpBtn.innerText="마이페이지" +// } +// else{ +// loginStatusBtn.setAttribute("href", `${apiUrl}/login`); +// loginStatusBtn.innerText="로그인" +// signUpBtn.setAttribute("href", `${apiUrl}/signup/agreement`); +// signUpBtn.innerText="회원가입" +// } -} +// } //mainpage 로드 후 loadData()실행 window.addEventListener('DOMContentLoaded', function() { - console.log("window.addEventListener 실행\n"); - loadData(); + //console.log("window.addEventListener 실행\n"); + loadloginData(); + //loadData(); // loadloginData(); }); From 1da208c43d5d16ffba581343e39cb14c480d44f5 Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 19:25:07 +0900 Subject: [PATCH 44/48] =?UTF-8?q?[FEAT]=20=EC=A7=80=EB=8F=84=20=EC=A4=91?= =?UTF-8?q?=EC=8B=AC=20=EB=B0=9B=EC=95=84=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/home.ctrl.js | 71 +++--------------------------------- src/public/js/council.js | 18 +++++++++ src/public/js/mainpage.js | 3 +- 3 files changed, 24 insertions(+), 68 deletions(-) diff --git a/src/controllers/home.ctrl.js b/src/controllers/home.ctrl.js index 5db89c5..ce2b9d8 100644 --- a/src/controllers/home.ctrl.js +++ b/src/controllers/home.ctrl.js @@ -51,25 +51,8 @@ const council = { await sendUniversityID(university_id, 'SendPostList'); const post_info = await receiveUniversityData('RecvPostList'); - console.log("home: post info:", post_info); + console.log("home: post info:", post_info); return post_info; - //return res.json({ result: 1 }); - - const university = new University(); - try { - //1. url로 id 얻어오기 - //2. post-service랑 통신해서 post_img_id, img_url 가져오기 - - //------- - const university_url = req.body.university_url; - console.log("university_url: ", university_url); - - const response = await university.getImages(university_url); - return res.json(response); - } catch (err) { - console.log("getImages error", err); - return res.status(500).json({ error: 'Internal Server Error' }); - } }, getUniversityName: async (req, res) => { @@ -88,33 +71,17 @@ const council = { console.error('getUniversityName error:', err); return res.status(500).json({ error: 'Internal Server Error' }); } - - //rabbitmq 적용 전 코드 - // console.log("home.ctrl의 getUniversityName "); - // const university = new University(); - - // if (!req.body || !req.body.university_url) { - // console.error("❌ university_url이 전달되지 않았습니다."); - // return res.status(400).json({ error: "university_url이 필요합니다." }); - // } - - // const response = await university.getUnversityUrlToName(req.body.university_url); - // console.log(response); - // return res.json(response); }, getUniversityLocation: async (req, res) => { - console.log("home.ctrl의 getUniversityLocation"); - console.log("req.body:", req.body); - try { + try { + console.log("home.ctrl의 getUniversityLocation "); const university_url = req.body.university_url; - - // RabbitMQ로 university_location 요청 및 수신 await sendUniversityURL(university_url, 'SendUniversityLocation'); - const university_location = await receiveUniversityData('RecvUniversityLocation'); + const university_location = await receiveUniversityData('RecvStartUniversityLocation'); + console.log("home: university location:", university_location); return res.json(university_location); - } catch (err) { console.error('getUniversityLocation error:', err); return res.status(500).json({ error: 'Internal Server Error' }); @@ -122,34 +89,6 @@ const council = { } } -// showUniversityNameList: async (req, res) => { -// const university_name = new University(); -// const response = await university_name.showUniversityNameList(); -// return res.json(response); -// }, - -// getUniversityName: async (req, res) => { -// const council = new Council(); -// const response = await council.getUniversityName(req.body.university_url); -// return res.json(response); -// }, - -// getCardNewsImageUrl: async (req, res) => { -// const council = new Council(); -// const response = await council.getUniversityID(req.body.university_url); -// const response2 = await council.getCardNewsImageUrl(response); -// return res.json(response2); -// }, - -// getUniversityLocation: async (req, res) => { -// const partner = new Partner(); -// const university_id = await partner.getUniversityID(req.body.university_url); -// const response = await partner.getUniversityLocation(university_id); -// return res.json(response); -// }, -// } - - module.exports = { output, mainpage, diff --git a/src/public/js/council.js b/src/public/js/council.js index ade9ad2..6cf45ed 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -144,6 +144,24 @@ const serviceKey = apiKeys.SERVICE_KEY; const endPoint = apiKeys.ENDPOINT; document.addEventListener("DOMContentLoaded", () => { + + const universityUrl = current_university_url; + const req = { + university_url: universityUrl + }; + + fetch(`${apiUrl}/getUniversityLocation`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(req), + }) + .then((res) => res.json()) + .then(res => { + console.log("kakao map: ", res); + }); + loadKakaoMap().then(() => { const container = document.getElementById('map'); if (!container) return console.error('#map 요소가 없습니다.'); diff --git a/src/public/js/mainpage.js b/src/public/js/mainpage.js index 6bc29f6..d7a4a5d 100644 --- a/src/public/js/mainpage.js +++ b/src/public/js/mainpage.js @@ -127,8 +127,7 @@ const loadloginData = async () => { // } //mainpage 로드 후 loadData()실행 -window.addEventListener('DOMContentLoaded', function() -{ +window.addEventListener('DOMContentLoaded', function() { //console.log("window.addEventListener 실행\n"); loadloginData(); //loadData(); From 708a44b3e4bb47b3cc6f83042c9033ed20d2687a Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Thu, 29 May 2025 19:35:34 +0900 Subject: [PATCH 45/48] =?UTF-8?q?[TEST]=20=EA=B0=80=EC=A0=B8=EC=98=A8=20?= =?UTF-8?q?=EC=A2=8C=ED=91=9C=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 6cf45ed..39cac7f 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -144,7 +144,7 @@ const serviceKey = apiKeys.SERVICE_KEY; const endPoint = apiKeys.ENDPOINT; document.addEventListener("DOMContentLoaded", () => { - + var university_location; const universityUrl = current_university_url; const req = { university_url: universityUrl @@ -160,8 +160,12 @@ document.addEventListener("DOMContentLoaded", () => { .then((res) => res.json()) .then(res => { console.log("kakao map: ", res); + res = university_location; }); + console.log("latitude: ", university_location.latitude); + console.log("longitude: ",university_location.longitude); + loadKakaoMap().then(() => { const container = document.getElementById('map'); if (!container) return console.error('#map 요소가 없습니다.'); From ebdda506c11c8582d2e2d41ca0d012beea61e4dd Mon Sep 17 00:00:00 2001 From: chaehyeon02 Date: Fri, 30 May 2025 01:08:23 +0900 Subject: [PATCH 46/48] =?UTF-8?q?[fix]=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 39cac7f..6860758 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -17,6 +17,7 @@ const navBar=document.getElementById("navbar"); //auth 로그인 정보 가져오기 let userInfo; const userApiUrl = baseUrls.user; +const postApiUrl = baseUrls.post; const postReactionApiUrl = baseUrls.postReaction; // 로그아웃 처리 함수 @@ -279,7 +280,7 @@ async function fetchImageUrls(imageData) { imgContainer.classList.add('swiper-slide'); const imgLink = document.createElement('a'); - imgLink.href = `${apiUrl}/postviewer/${currentData.post_id}`; // 이미지 클릭 시 postviewer 페이지로 이동하는 URL 생성 + imgLink.href = `${postApiUrl}/postviewer/${currentData.post_id}`; // 이미지 클릭 시 postviewer 페이지로 이동하는 URL 생성 imgLink.target = '_self'; const imgElement = document.createElement('img'); From 0cc4f9c082ca02e848d627bec9de0eb93b61254e Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Fri, 30 May 2025 08:57:06 +0000 Subject: [PATCH 47/48] =?UTF-8?q?[FEAT]=20=ED=95=99=EA=B5=90=EB=B3=84=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/council.js | 47 ++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/public/js/council.js b/src/public/js/council.js index 6860758..f0a269e 100644 --- a/src/public/js/council.js +++ b/src/public/js/council.js @@ -144,40 +144,49 @@ function setCenter(map,latitude,longitude){ const serviceKey = apiKeys.SERVICE_KEY; const endPoint = apiKeys.ENDPOINT; -document.addEventListener("DOMContentLoaded", () => { - var university_location; +document.addEventListener("DOMContentLoaded", async () => { + var university_location = []; const universityUrl = current_university_url; const req = { university_url: universityUrl }; - fetch(`${apiUrl}/getUniversityLocation`, { + try { + const res = await fetch(`${apiUrl}/getUniversityLocation`, { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify(req), - }) - .then((res) => res.json()) - .then(res => { - console.log("kakao map: ", res); - res = university_location; - }); - - console.log("latitude: ", university_location.latitude); - console.log("longitude: ",university_location.longitude); + body: JSON.stringify(req), + }); + const data = await res.json(); + university_location[0] = data.latitude; + university_location[1] = data.longitude; + } catch (err) { + console.error("지도 정보 요청 중 에러:", err); + } + console.log("university_location[0]: ", university_location[0]); + console.log("university_location[1]: ", university_location[1]); + loadKakaoMap().then(() => { const container = document.getElementById('map'); if (!container) return console.error('#map 요소가 없습니다.'); - const map = new kakao.maps.Map(container, { - center: new kakao.maps.LatLng(37.59169598260442, 127.02220971655647), // 초기 위치 - level: 3 - }); + let map; + if (university_location.length == 0) { + map = new kakao.maps.Map(container, { + center: new kakao.maps.LatLng(37.59169598260442, 127.02220971655647), // 초기 위치 + level: 3 + }); + } + else { + map = new kakao.maps.Map(container, { + center: new kakao.maps.LatLng(university_location[0], university_location[1]), // 초기 위치 + level: 3 + }); + } - // setCenter(); - // bounds_changed 이벤트 등록 kakao.maps.event.addListener(map, 'bounds_changed', () => { const bounds = map.getBounds(); const swLatlng = bounds.getSouthWest(); From 259e13887c8e47f77c6c1d379c50d8e69aeae487 Mon Sep 17 00:00:00 2001 From: 5IHYUN Date: Sat, 31 May 2025 05:42:35 +0000 Subject: [PATCH 48/48] =?UTF-8?q?[FIX]=20=EC=99=B8=EB=B6=80ip=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/js/apiUrl.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/public/js/apiUrl.js b/src/public/js/apiUrl.js index 7734789..7c1b97e 100644 --- a/src/public/js/apiUrl.js +++ b/src/public/js/apiUrl.js @@ -1,9 +1,8 @@ -export const apiUrl = 'http://34.47.84.123:3001'; +export const apiUrl = 'http://34.22.87.148:3001'; // 마이크로서비스별 API 주소 export const baseUrls = { - post: "http://34.47.84.123:3000", - postReaction: "http://34.47.84.123:3002", - partner: "http://34.47.84.123:3003", - user: "http://34.47.84.123:3004" + post: "http://34.22.87.148:3000", + partner: "http://34.22.87.148:3003", + user: "http://34.22.87.148:3004" };