moderate-text is a FlexService intended to be used as a FlexFunction. It has several functions, some of which are designed to be used as custom endpoints (i.e.
checkForProfanity) while the other (
cleanCommentOnPreSave) is intended to be used as a collection hook that runs
onPreSave (i.e. prior to a create or update).
moderateText method only assumes that you are sending a
message property in the POST body, which is cleaned of anything that appears to be profanity and then returned.
cleanCommentOnPreSave method only assumes that whatever you are inserting has a
message property, which is cleaned of anything that appears to be profanity and then inserted or updated. The function could be easily modified to alter a different property of an entity by changing the name of the property on lines 23, 24 and 27.