function setUserRole({ payload }) {
if (payload.role !== 'admin') {
return models.User
.find({ id: payload.userId })
.setPaymentProfileVerifiedStatus(false)
.updateRole(payload.role);
}
return models.User
.find({ id: payload.userId })
.updateRole(payload.role);
}
// this is a server function that will
function setUserRole({ payload }) {
const dictOfFunctions = {};
const param = payload.role;
const mimeType = payload.contentType;
dictOfFunctions['admin'] = () => { ... };
dictOfFunctions['buyer'] = () => { ... };
dictOfFunctions['seller'] = () => { ... };
dictOfFunctions['editor'] = () => { ... };
return dictOfFunctions[param]();
}
dictOfFunctions['application/vnd.example.v1+json/buyer'] = () => ...
dictOfFunctions['application/vnd.example.v2+json/buyer'] = () => ...
...

nobody leaves the cave before the end of a new dawn https://gist.github.com/dualyticalchemy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store