From 208d329ff5e4ed5a351d2f88bc93ed45e4a133c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=EC=A1=B0=EB=8C=80=ED=9D=AC?= <joedaehui@ajou.ac.kr>
Date: Mon, 9 Dec 2024 08:43:31 +0900
Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20log?=
 =?UTF-8?q?=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 controllers/friendController.js | 25 +++++++++++++++++++++++--
 services/scheduleService.js     | 13 ++++++++++++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/controllers/friendController.js b/controllers/friendController.js
index e930a6e..19dcb98 100644
--- a/controllers/friendController.js
+++ b/controllers/friendController.js
@@ -97,9 +97,29 @@ class friendController {
     async acceptRequest(req, res) {
         try {
             return await performanceMonitor.measureAsync('acceptFriendRequest', async () => {
+                if (!req.user || !req.user.id) {
+                    return res.status(401).json({
+                        success: false,
+                        error: {
+                            message: '�몄쬆�섏� �딆� �ъ슜�먯엯�덈떎.',
+                            code: 'UNAUTHORIZED'
+                        }
+                    });
+                }
+    
                 const userId = req.user.id;
-                const { friendId } = req.params;
-
+                const friendId = parseInt(req.params.friendId, 10);
+    
+                if (!friendId || isNaN(friendId)) {
+                    return res.status(400).json({
+                        success: false,
+                        error: {
+                            message: '�좏슚�섏� �딆� 移쒓뎄 ID�낅땲��.',
+                            code: 'INVALID_FRIEND_ID'
+                        }
+                    });
+                }
+    
                 const result = await FriendService.acceptFriendRequest(userId, friendId);
                 return res.status(200).json({
                     success: true,
@@ -107,6 +127,7 @@ class friendController {
                 });
             });
         } catch (error) {
+            console.error('Friend request accept error:', error);
             return res.status(400).json({
                 success: false,
                 error: {
diff --git a/services/scheduleService.js b/services/scheduleService.js
index 6c66d7f..e9700e4 100644
--- a/services/scheduleService.js
+++ b/services/scheduleService.js
@@ -27,11 +27,22 @@ class ScheduleService {
         const scheduleData = time_indices.map(time_idx => ({
             user_id: userId,
             title,
-            time_idx,
+            time_idx: parseInt(time_idx, 10),
             is_fixed
         }));
 
         try {
+            if (!userId || !title || !time_indices) {
+                throw new Error('Required parameters missing');
+            }
+    
+            console.log('Creating schedule with data:', {
+                userId,
+                title,
+                is_fixed,
+                time_indices
+            });
+
             const createdSchedules = await Schedule.bulkCreate(scheduleData, {
                 transaction,
                 returning: true,
-- 
GitLab