@@ -20,12 +20,8 @@ const SizeProfile = mongoose.model('sizeProfiles', sizeProfileSchema)
2020// 사이즈 : backend -> frontend
2121router . get ( '/api/size' , async ( req , res ) => {
2222 const { userId } = req . query
23- console . log ( `get /userInfo/api/size ${ userId } ` )
24-
2523 try {
2624 const sizeProfile = await SizeProfile . findOne ( { userId : userId } )
27- console . log ( sizeProfile )
28-
2925 res . status ( 201 ) . json ( { success : true , message : sizeProfile } )
3026 } catch ( error ) {
3127 console . error ( 'Error finding size :' , error )
@@ -43,7 +39,7 @@ router.get('/api/info', async (req, res) => {
4339 . status ( 404 )
4440 . json ( { success : false , message : 'The user was not found.' } )
4541 }
46- console . log ( user )
42+
4743 res . status ( 201 ) . json ( { success : true , user } )
4844 } catch ( error ) {
4945 console . error ( 'User lookup errors :' , error )
@@ -54,11 +50,10 @@ router.get('/api/info', async (req, res) => {
5450 }
5551} )
5652
53+ // 사용자 정보 업데이트
5754router . put ( '/api/privacy' , async ( req , res ) => {
58- // const user = JSON.parse(req.body)
5955 const user = req . body
6056 const userId = user . userId
61- console . log ( user )
6257
6358 const update = {
6459 $set : user ,
@@ -67,18 +62,33 @@ router.put('/api/privacy', async (req, res) => {
6762 try {
6863 const result = await User . findByIdAndUpdate ( { _id : userId } , update )
6964
70- // if (result) {}
7165 res . status ( 201 ) . json ( { success : true , code : 0 , user : result } )
7266 } catch ( error ) {
73- // console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
74- // console.log(error.code)
75- // console.log('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
76- // console.error(error.code, error.message)
7767 res . status ( 500 ) . json ( {
7868 success : false ,
7969 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.' ,
8292 } )
8393 }
8494} )
0 commit comments