constseries=awaitAnime.findOne(/*{$or: [*/{id:req.params.id.toLowerCase()}/*, {numericalId: req.params.id}]}*/);//TODO make sure all ID calls are lowercased
constseries=req.params.id.match(/^\d+$/)?awaitAnime.findOne({numericalId:req.params.id.toLowerCase()}):awaitAnime.findOne({id:req.params.id.toLowerCase()});//TODO make sure all ID calls are lowercased
if(!req.body.name){returnres.status(400).send("You did not provide a new name in your body.");}
if(!req.body.name.match(/^[\w_\-!?.:; ]+$/gm)||req.body.name.length>150){returnres.status(400).send("Your new name is too long or contains illegal characters.");}
try{
series.name=req.body.name.trim();
pushEdit("Updated name",req,series);
returnseries.save()
.then(()=>res.send("Name updated."))
.catch(()=>res.status(500).send("There was an error trying to update your name. Please try again."));
}catch{returnres.status(500).send("There was an error trying to update your name. Please try again.");}