@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
} ) ;
10
10
} ;
11
11
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
12
- exports . handleAddQuestion = exports . handleDeleteQuestion = exports . handleGetQuestions = void 0 ;
12
+ exports . handleAddQuestion = exports . handleUpdateQuestion = exports . handleDeleteQuestion = exports . handleGetQuestions = void 0 ;
13
13
const question_service_1 = require ( "./question.service" ) ;
14
14
const firestore_1 = require ( "firebase/firestore" ) ;
15
15
function handleGetQuestions ( req , res ) {
@@ -74,6 +74,30 @@ function handleDeleteQuestion(req, res) {
74
74
} ) ;
75
75
}
76
76
exports . handleDeleteQuestion = handleDeleteQuestion ;
77
+ function handleUpdateQuestion ( req , res ) {
78
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
79
+ const questionId = req . params . questionId ;
80
+ try {
81
+ const { title, tags, categories, constraints, difficulty, description, examples, } = req . body ;
82
+ console . log ( `updating question ${ questionId } : ${ title } ` ) ;
83
+ const question = yield ( 0 , question_service_1 . updateQuestion ) ( questionId , {
84
+ title : title ,
85
+ tags : tags ,
86
+ categories : categories ,
87
+ constraints : constraints ,
88
+ difficulty : difficulty ,
89
+ description : description ,
90
+ examples : examples ,
91
+ } ) ;
92
+ res . status ( 200 ) . send ( question ) ;
93
+ }
94
+ catch ( err ) {
95
+ console . log ( err ) ;
96
+ res . status ( 500 ) . send ( err ) ;
97
+ }
98
+ } ) ;
99
+ }
100
+ exports . handleUpdateQuestion = handleUpdateQuestion ;
77
101
function handleAddQuestion ( req , res ) {
78
102
return __awaiter ( this , void 0 , void 0 , function * ( ) {
79
103
try {
0 commit comments