Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/108] 3000->8080서버 요청 시 internal API 사용하도록 변경 #109

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions socket/apis/chatApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ async function fetchChatroomUuid(socket) {
try {
logger.http("Sending 'fetch chatroom UUID' API request", `memberId:${socket.memberId}, socketId:${socket.id}`);

const response = await axios.get(`${API_SERVER_URL}/v1/member/chatroom/uuid`, {
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
});
const response = await axios.get(`${API_SERVER_URL}/v1/internal/${socket.memberId}/chatroom/uuid`);

if (response.data.isSuccess) {
logger.info("Successfully fetched chatroom UUID", `memberId:${socket.memberId}`);
Expand Down Expand Up @@ -54,11 +50,7 @@ async function postChatMessage(socket, chatroomUuid, requestData) {
try {
logger.http("Sending POST request to save chat message", `socketId:${socket.id}, chatroomUuid:${chatroomUuid}, requestData:${JSON.stringify(requestData)}`);

const response = await axios.post(`${API_SERVER_URL}/v1/chat/${chatroomUuid}`, requestData, {
headers: {
Authorization: `Bearer ${socket.token}`,
},
});
const response = await axios.post(`${API_SERVER_URL}/v1/internal/${socket.memberId}/chat/${chatroomUuid}`, requestData);
if (response.data.isSuccess) {
logger.info("Successfully saved chat message", `socketId:${socket.id}, chatroomUuid:${chatroomUuid}, messageId:${response.data.result.messageId}`);
return response.data.result;
Expand Down Expand Up @@ -89,11 +81,7 @@ async function postChatMessage(socket, chatroomUuid, requestData) {
*/
async function startTestChattingByMatching(socket, targetMemberId) {
try {
const response = await axios.get(`${API_SERVER_URL}/v1/chat/start/matching/${socket.memberId}/${targetMemberId}`, {
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
});
const response = await axios.get(`${API_SERVER_URL}/v1/chat/start/matching/${socket.memberId}/${targetMemberId}`);
if (response.data.isSuccess) {
return response.data.result;
}
Expand Down
6 changes: 1 addition & 5 deletions socket/apis/friendApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const API_SERVER_URL = config.apiServerUrl;
async function fetchFriends(socket) {
try {
logger.http("Sending 'fetch friends' API request", `memberId:${socket.memberId}`);
const response = await axios.get(`${API_SERVER_URL}/v1/friends/ids`, {
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
});
const response = await axios.get(`${API_SERVER_URL}/v1/internal/${socket.memberId}/friends/ids`);
if (response.data.isSuccess) {
logger.info("Successfully fetched friends", `memberId:${socket.memberId}, friendIdList:${response.data.result}`);
return response.data.result;
Expand Down
66 changes: 17 additions & 49 deletions socket/apis/matchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,18 @@ const API_SERVER_URL = config.apiServerUrl;
*/
async function fetchMatchingApi(socket, request) {
try {
const gameStyleIdList = [request.gameStyle1, request.gameStyle2, request.gameStyle3].filter(item => item);
const gameStyleIdList = [request.gameStyle1, request.gameStyle2, request.gameStyle3].filter((item) => item);
logger.http("Sending matching API request", `memberId:${socket.memberId}, gameMode:${request.gameMode}, gameStyleIdList:${gameStyleIdList}`);

const response = await axios.post(
`${API_SERVER_URL}/v1/matching/priority`,
{
gameMode: request.gameMode,
mike: request.mike,
matchingType: request.matchingType,
mainP: request.mainP,
subP: request.subP,
wantP: request.wantP,
gameStyleIdList: gameStyleIdList,
},
{
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
}
);
const response = await axios.post(`${API_SERVER_URL}/v1/internal/${socket.memberId}/matching/priority`, {
gameMode: request.gameMode,
mike: request.mike,
matchingType: request.matchingType,
mainP: request.mainP,
subP: request.subP,
wantP: request.wantP,
gameStyleIdList: gameStyleIdList,
});
if (response.data.isSuccess) {
logger.info("Successfully fetched matching data from API", `memberId:${socket.memberId}`);
return response.data.result;
Expand Down Expand Up @@ -67,18 +59,10 @@ async function updateBothMatchingStatusApi(socket, status, targetMemberId) {
`senderMemberId:${socket.memberId}, targetMemberId:${targetMemberId}, status:${status}, gameMode:${socket.gameMode}`
);

const response = await axios.patch(
`${API_SERVER_URL}/v1/matching/status/target/${targetMemberId}`,
{
status: status,
gameMode: socket.gameMode,
},
{
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
}
);
const response = await axios.patch(`${API_SERVER_URL}/v1/internal/${socket.memberId}/matching/status/target/${targetMemberId}`, {
status: status,
gameMode: socket.gameMode,
});

if (response.data.isSuccess) {
logger.info(
Expand Down Expand Up @@ -124,7 +108,7 @@ async function updateMatchingStatusApi(socket, status) {
logger.http("Sending 'update matching status' API request", `memberId:${socket.memberId}, status:${status}, gameMode:${socket.gameMode}`);

const response = await axios.patch(
`${API_SERVER_URL}/v1/matching/status`,
`${API_SERVER_URL}/v1/internal/${socket.memberId}/matching/status`,
{
status: status,
gameMode: socket.gameMode,
Expand Down Expand Up @@ -167,15 +151,7 @@ async function matchingFoundApi(socket, targetMemberId) {
try {
logger.http("Sending 'matching found' API request", `memberId:${socket.memberId}, targetMemberId:${targetMemberId}, gameMode:${socket.gameMode}`);

const response = await axios.patch(
`${API_SERVER_URL}/v1/matching/found/target/${targetMemberId}/${socket.gameMode}`,
{},
{
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
}
);
const response = await axios.patch(`${API_SERVER_URL}/v1/internal/${socket.memberId}/matching/found/target/${targetMemberId}/${socket.gameMode}`, {});

if (response.data.isSuccess) {
logger.info("Successfully updated 'matching found' status", `memberId:${socket.memberId}, targetMemberId:${targetMemberId}, gameMode:${socket.gameMode}`);
Expand Down Expand Up @@ -214,15 +190,7 @@ async function matchingSuccessApi(socket, targetMemberId) {
try {
logger.http("Sending 'matching success' API request", `senderMemberId:${socket.memberId}, targetMemberId:${targetMemberId}, gameMode:${socket.gameMode}`);

const response = await axios.patch(
`${API_SERVER_URL}/v1/matching/success/target/${targetMemberId}/${socket.gameMode}`,
{},
{
headers: {
Authorization: `Bearer ${socket.token}`, // Include JWT token in header
},
}
);
const response = await axios.patch(`${API_SERVER_URL}/v1/internal/${socket.memberId}/matching/success/target/${targetMemberId}/${socket.gameMode}`, {});

if (response.data.isSuccess) {
logger.info(
Expand Down
Loading