@@ -6,6 +6,7 @@ import createToken, { Payload } from "../utils/token.utils";
66import upload from "../utils/multer" ;
77import passport from "passport" ;
88import userService from "../services/userService" ;
9+ import { uploadFiles } from "../middlewares/uploadFile" ;
910
1011const router = Router ( ) ;
1112
@@ -23,7 +24,7 @@ interface User {
2324}
2425
2526interface SignUpCustomer extends User {
26- imageUrl : Express . Multer . File ;
27+ imageUrl : string [ ] ;
2728 services : number [ ] ;
2829 regions : number [ ] ;
2930}
@@ -33,7 +34,7 @@ interface SignUpMover extends User {
3334 career : number ;
3435 introduction : string ;
3536 description : string ;
36- imageUrl : Express . Multer . File ;
37+ imageUrl : string [ ] ;
3738 services : number [ ] ;
3839 regions : number [ ] ;
3940}
@@ -66,21 +67,17 @@ router.post("/signout", (_, res) => {
6667
6768router . post (
6869 "/signup/customer" ,
69- upload . single ( "imageUrl" ) ,
70+ upload . array ( "imageUrl" ) ,
71+ uploadFiles ,
7072 asyncHandle ( async ( req , res , next ) => {
7173 try {
7274 const signUpCustomer : SignUpCustomer = {
7375 ...req . body ,
74- imageUrl : req . file ! ,
75- services : Array . isArray ( req . body . services )
76- ? req . body . services . map ( Number )
77- : JSON . parse ( req . body . services ) . map ( Number ) ,
78- regions : Array . isArray ( req . body . regions )
79- ? req . body . regions . map ( Number )
80- : JSON . parse ( req . body . regions ) . map ( Number ) ,
76+ imageUrl : req . fileUrls ,
77+ services : JSON . parse ( req . body . services ) . map ( Number ) ,
78+ regions : JSON . parse ( req . body . regions ) . map ( Number ) ,
8179 isOAuth : req . body . isOAuth === "true" ,
8280 } ;
83-
8481 await authService . signUpCustomer ( signUpCustomer ) ;
8582 res . status ( 204 ) . send ( ) ;
8683 } catch ( error ) {
@@ -91,20 +88,17 @@ router.post(
9188
9289router . post (
9390 "/signup/mover" ,
94- upload . single ( "imageUrl" ) ,
91+ upload . array ( "imageUrl" ) ,
92+ uploadFiles ,
9593 asyncHandle ( async ( req , res , next ) => {
9694 try {
9795 const SignUpMover : SignUpMover = {
9896 ...req . body ,
99- imageUrl : req . file ! ,
100- services : Array . isArray ( req . body . services )
101- ? req . body . services . map ( Number )
102- : JSON . parse ( req . body . services ) . map ( Number ) ,
103- regions : Array . isArray ( req . body . regions )
104- ? req . body . regions . map ( Number )
105- : JSON . parse ( req . body . regions ) . map ( Number ) ,
97+ imageUrl : req . fileUrls ,
98+ services : JSON . parse ( req . body . services ) . map ( Number ) ,
99+ regions : JSON . parse ( req . body . regions ) . map ( Number ) ,
106100 isOAuth : req . body . isOAuth === "true" ,
107- career : Number ( req . body . career ) ,
101+ career : parseInt ( req . body . career ) ,
108102 } ;
109103 await authService . signUpMover ( SignUpMover ) ;
110104 res . status ( 204 ) . send ( ) ;
0 commit comments