diff --git a/controllers/match-user-controller.js b/controllers/match-user-controller.js index 98ebb9c..a47ced8 100644 --- a/controllers/match-user-controller.js +++ b/controllers/match-user-controller.js @@ -53,10 +53,26 @@ const getMatchUser = async (req, res) => { // @route GET /matchUsers/getMatch // @description: Construct matches for users // @access: Private -const matching = async (req, res) => { - ///// Later call K-clusters from Flask services +const fetchMatchPairs = async (req, res) => { + try { + const response = await fetch('http://localhost:5002/matchPairs', { + method: 'GET', + headers: { + 'Content-Type': 'application/json' + } + }); + + if (!response.ok) { + throw new Error(`Error: ${response.status}`); + } + + const pairingData = await response.json(); + return res.status(200).json(pairingData); + } catch (error) { + console.error('Error fetching match pairs:', error); + return res.status(500).json({ error: 'Internal Server Error' }); + } - return res.status(201).json("Chat Matching Algo"); }; // @route POST /matchUsers @@ -204,5 +220,5 @@ module.exports = { deleteMatchUser, updateMatchUser, deleteAllMatchUsers, - matching, + fetchMatchPairs, }; diff --git a/routes/match-user-routes.js b/routes/match-user-routes.js index 260cc04..36667bb 100644 --- a/routes/match-user-routes.js +++ b/routes/match-user-routes.js @@ -8,12 +8,12 @@ const { updateMatchUser, deleteMatchUser, deleteAllMatchUsers, - matching, + fetchMatchPairs, } = require("../controllers/match-user-controller"); matchUserRouter.use(requireAuth); matchUserRouter.get("/", getMatchUsers); -matchUserRouter.get('/matching', matching) +matchUserRouter.get('/matching', fetchMatchPairs); matchUserRouter.get("/:userId", getMatchUser); matchUserRouter.post("/", createMatchUser); matchUserRouter.patch("/:userId", updateMatchUser);