Example #1
0
File: room.ts Project: 7h1b0/Anna
 .post((req, res) => {
   const isValid = Room.validate(req.body);
   if (!isValid) {
     res.sendStatus(400);
   } else {
     const userId = res.locals.user.userId;
     Room.save({ ...req.body, userId })
       .then(newRoomId => res.status(201).json(newRoomId))
       .catch(err => res.status(500).send({ err }));
   }
 });
Example #2
0
File: room.ts Project: 7h1b0/Anna
 .patch((req, res) => {
   const isValid = Room.validate(req.body);
   if (!isValid) {
     res.sendStatus(400);
   } else {
     Room.findByIdAndUpdate(req.params.room_id, req.body)
       .then(rowsAffected => {
         if (rowsAffected < 1) {
           res.sendStatus(404);
         } else {
           res.sendStatus(204);
         }
       })
       .catch(err => res.status(500).send({ err }));
   }
 })