File tree 3 files changed +15
-6
lines changed
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const aiAPI = process.env.AI_API
18
18
19
19
const allowedOrigins = [
20
20
'http://localhost:3000' ,
21
+ 'http://localhost:3001' ,
21
22
'http://www.model-fit.kro.kr' ,
22
23
aiAPI ,
23
24
]
@@ -73,9 +74,7 @@ const infoRouter = require('./routes/UserInfo')
73
74
app . use ( '/userInfo' , infoRouter )
74
75
75
76
const fittingRouter = require ( './routes/FittingImage' )
76
- const clothUploadRouter = require ( './routes/UploadClothImage' )
77
77
app . use ( '/api' , fittingRouter )
78
- app . use ( '/api' , clothUploadRouter )
79
78
80
79
const clothRouter = require ( './routes/Clothes' )
81
80
app . use ( '/cloth' , clothRouter )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const aws = require('@aws-sdk/client-s3')
2
2
const multer = require ( 'multer' )
3
3
const multers3 = require ( 'multer-s3' )
4
4
const path = require ( 'path' )
5
+ const { ObjectId } = require ( 'mongodb' )
5
6
6
7
const { S3Client, PutObjectCommand } = aws
7
8
@@ -26,7 +27,14 @@ const ImageUploader = multer({
26
27
s3 : s3 ,
27
28
bucket : 'bigprogect-bucket' ,
28
29
key : ( req , file , callback ) => {
29
- const userId = req . body . userId || req . query . userId
30
+ /*
31
+ νμκ°μ
μ μ 체 μ΄λ―Έμ§ μ
λ‘λ νλ©΄ μμ§ DBμ 컬λΌμ΄ μμ.
32
+ => userId νλλ 무쑰건 undefinedκ° λ¨.
33
+ => s3/undefined/μ μ΄λ―Έμ§κ° μ μ₯ λ¨
34
+ => idλ₯Ό μμ±ν μ μκ² [ ?? new ObjectId().toString() ] μΆκ°
35
+ */
36
+ const userId =
37
+ ( req . body . userId || req . query . userId ) ?? new ObjectId ( ) . toString ( )
30
38
const uploadDirectory = req . query . directory ?? userId
31
39
const extension = path . extname ( file . originalname )
32
40
if ( ! allowedExtensions . includes ( extension ) ) {
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ router.post(
27
27
favoriteStyle,
28
28
} = req . body
29
29
const file = req . file ? req . file . location : undefined
30
+ // μ μ₯ν νμΌ κ²½λ‘μμ userID μΆμΆ
31
+ const userId = req . file . key . split ( '/' ) [ 0 ]
30
32
31
33
try {
32
34
const userExists = await User . findOne ( { email : userEmail } )
@@ -40,6 +42,7 @@ router.post(
40
42
41
43
// μλ‘μ΄ μ¬μ©μ μμ± λ° μ μ₯
42
44
const newUser = new User ( {
45
+ _id : userId ,
43
46
email : userEmail ,
44
47
name,
45
48
phoneNumber,
@@ -63,9 +66,8 @@ router.post(
63
66
}
64
67
65
68
// μ¬μ΄μ¦ λ°μμ€κΈ°
66
- const responseFromAIApi = await axios . post ( aiApiEndpoint , {
67
- height,
68
- weight,
69
+ const responseFromAIApi = await axios . get ( aiApiEndpoint , {
70
+ params : { height : height , weight : weight } ,
69
71
} )
70
72
71
73
if ( responseFromAIApi . data . error ) {
You canβt perform that action at this time.
0 commit comments