@@ -20,12 +20,8 @@ const SizeProfile = mongoose.model('sizeProfiles', sizeProfileSchema)
20
20
// 사이즈 : backend -> frontend
21
21
router . get ( '/api/size' , async ( req , res ) => {
22
22
const { userId } = req . query
23
- console . log ( `get /userInfo/api/size ${ userId } ` )
24
-
25
23
try {
26
24
const sizeProfile = await SizeProfile . findOne ( { userId : userId } )
27
- console . log ( sizeProfile )
28
-
29
25
res . status ( 201 ) . json ( { success : true , message : sizeProfile } )
30
26
} catch ( error ) {
31
27
console . error ( 'Error finding size :' , error )
@@ -43,7 +39,7 @@ router.get('/api/info', async (req, res) => {
43
39
. status ( 404 )
44
40
. json ( { success : false , message : 'The user was not found.' } )
45
41
}
46
- console . log ( user )
42
+
47
43
res . status ( 201 ) . json ( { success : true , user } )
48
44
} catch ( error ) {
49
45
console . error ( 'User lookup errors :' , error )
@@ -54,11 +50,10 @@ router.get('/api/info', async (req, res) => {
54
50
}
55
51
} )
56
52
53
+ // 사용자 정보 업데이트
57
54
router . put ( '/api/privacy' , async ( req , res ) => {
58
- // const user = JSON.parse(req.body)
59
55
const user = req . body
60
56
const userId = user . userId
61
- console . log ( user )
62
57
63
58
const update = {
64
59
$set : user ,
@@ -67,18 +62,33 @@ router.put('/api/privacy', async (req, res) => {
67
62
try {
68
63
const result = await User . findByIdAndUpdate ( { _id : userId } , update )
69
64
70
- // if (result) {}
71
65
res . status ( 201 ) . json ( { success : true , code : 0 , user : result } )
72
66
} catch ( error ) {
73
- // console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
74
- // console.log(error.code)
75
- // console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
76
- // console.error(error.code, error.message)
77
67
res . status ( 500 ) . json ( {
78
68
success : false ,
79
69
code : error . code ,
80
- // message: 'An error occurred while updating the document.',
81
- message : 'An' ,
70
+ message : 'An error occurred while updating the document.' ,
71
+ } )
72
+ }
73
+ } )
74
+
75
+ // 사용자 신체 이미지 경로 전송
76
+ router . get ( '/api/userimage' , async ( req , res ) => {
77
+ const { userId } = req . query
78
+
79
+ try {
80
+ const user = await User . findById ( userId )
81
+ if ( ! user ) {
82
+ return res
83
+ . status ( 404 )
84
+ . json ( { success : false , message : 'The user was not found.' } )
85
+ }
86
+ res . status ( 200 ) . json ( { success : true , image : user . file } )
87
+ } catch ( error ) {
88
+ console . error ( 'User lookup errors :' , error )
89
+ res . status ( 500 ) . json ( {
90
+ success : false ,
91
+ message : 'An error occurred during user lookup.' ,
82
92
} )
83
93
}
84
94
} )
0 commit comments