//Router file. After doing all your imports at beginning of file
const router = express.Router();
app.use('/pathforpostrequests', router);
router.patch('/:name', controller.updatePerson, (req, res, next) => {
res.status(200).json(res.locals.person);
});
// Controller file. After doing all your imports at beginning of file. Person is an example mongo schema you will need to setup in a schema file.
const controller = {
updatePerson (req, res, next) {
Person.findOne({ firstName: req.params.name }).exec()
.then((result) => {
result.firstName = req.body.firstName;
result.save();
res.locals.person = result;
next();
})
},
}