Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports = function(app) {
- app.models().forEach(Model => {
- const original = Model.sharedClass.methods;
- // Iterate over each model remote method
- Model.sharedClass.methods = () =>
- original.call(Model.sharedClass).map(overwriteMethodProperties);
- });
- app.emit('modelRemoted');
- };
- function overwriteMethodProperties(method) {
- // Use the longer description for the 'notes' and just use the method name for the 'description'
- method.originalDescription = method.originalDescription || method.description;
- method.notes = method.originalDescription;
- method.description = methodDescription(method);
- return method;
- }
- function methodDescription(method) {
- // Handle related methods by stripping out the __s
- let name = method.name
- .replace(/__(.+)__/, '$1 ')
- .replace(/([A-Z])/g, ' $1')
- .toLowerCase();
- return name
- .slice(0, 1)
- .toUpperCase()
- .concat(name.slice(1));
- }
Add Comment
Please, Sign In to add comment