- const obj = req.body.newObj;
- GameModel.update(gid, obj, (err) => {
- if (!!err)
- return res.json(err);
+ let error = "";
+ if (!gid.toString().match(/^[0-9]+$/))
+ error = "Wrong game ID";
+ const obj = req.body.newObj;
+ error = GameModel.checkGameUpdate(obj);
+ if (!!error)
+ return res.json({errmsg: error});
+ GameModel.update(gid, obj); //no callback here (several operations)
+ if (!!obj.move || !!obj.score)
+ {