In cloud.js, can we have helper functions that cloud functions can call?
For example: to check if a user is admin in multiple cloud functions, it’s better to have a normal JS function that we can call.
I’ve in cloud.js:
async function isUserAdmin(user) {
// check if user is admin
}
// use the helper in a cloud function
Moralis.Cloud.define(
"doSomethingThatOnlyAdminCanDo",
async (request) => {
const isUserAdmin= isUserAdmin(request.user);
},
{
requireUser: true,
}
);