@@ -3,7 +3,7 @@ import validatorErrorChecker from '../../middlewares/validatorErrorChecker';
33import { body , param , query } from 'express-validator' ;
44import HTTPError from '../../utils/HTTPError' ;
55import jwtVerifier from '../../middlewares/jwtVerifier' ;
6- import { createCalendar , deleteSchedule , getCalendar } from './service' ;
6+ import { createCalendar , deleteSchedule , getCalendar , patchSchedule } from './service' ;
77
88const router = Router ( ) ;
99router . use ( express . urlencoded ( { extended : false } ) ) ;
@@ -79,4 +79,32 @@ router.delete('/:scheduleid',
7979 }
8080)
8181
82+ router . patch ( '/:scheduleid' ,
83+ jwtVerifier ,
84+ param ( "scheduleid" ) . isNumeric ( ) . notEmpty ( ) ,
85+ body ( "color" ) . optional ( ) . isString ( ) ,
86+ body ( "memo" ) . optional ( ) . isString ( ) ,
87+ body ( "users" ) . optional ( ) ,
88+ body ( "users.*" ) . toInt ( ) ,
89+ body ( "start" ) . optional ( ) . toInt ( ) ,
90+ body ( "end" ) . optional ( ) . toInt ( ) ,
91+ validatorErrorChecker ,
92+ async ( req , res , next ) => {
93+ try {
94+ const uid = req . uid ! ;
95+ const scheduleid = parseInt ( req . params . scheduleid ) ;
96+ const color : string | undefined = req . body . color ;
97+ const memo : string | undefined = req . body . memo ;
98+ const userList : number [ ] | undefined = req . body . users ;
99+ const start : number | undefined = req . body . start ;
100+ const end : number | undefined = req . body . end ;
101+
102+ await patchSchedule ( uid , scheduleid , color , memo , userList , start , end ) ;
103+ }
104+ catch ( e ) {
105+ next ( e ) ;
106+ }
107+ }
108+ )
109+
82110export default router ;
0 commit comments