node-express-mongodb-jwt-rest-api-skeleton
Version:
Node.js express.js MongoDB JWT REST API - This is a basic API REST skeleton written on JavaScript using async/await. Great for building a starter web API for your front-end (Android, iOS, Vue, react, angular, or anything that can consume an API)
21 lines (18 loc) • 577 B
JavaScript
const { isIDGood, handleError } = require('../../middleware/utils')
const { matchedData } = require('express-validator')
const { updateProfileInDB } = require('./helpers')
/**
* Update profile function called by route
* @param {Object} req - request object
* @param {Object} res - response object
*/
const updateProfile = async (req, res) => {
try {
const id = await isIDGood(req.user._id)
req = matchedData(req)
res.status(200).json(await updateProfileInDB(req, id))
} catch (error) {
handleError(res, error)
}
}
module.exports = { updateProfile }