crud/templates/crud.js

/**
 * Get the contents of a new Crud model, and create the corresponding controller, router, and validators.
 * @type {function(*=, *=): string}
 * @param {string} name - the name of the model class to be created
 * @param {string} original_name - the Flitter canonical name of the resource
 * @returns {string}
 */
module.exports = exports = (name, original_name, ctx) => {
    
    // create the controller
    ctx.services.cli.invoke('new', ['crud:controller', original_name])
    
    // create the router
    ctx.services.cli.invoke('new', ['crud:router', original_name])
    
    // create the validator
    ctx.services.cli.invoke('new', ['form', 'crud:'+original_name])
    
    // return contents of new model
    return ctx.services.cli.loaded_templates.model.template(name, original_name)
}