lib/router/index.js
function generateGenericControllers(controllers, models) {
        var genericControllers = {},
            genericRoute = [];

        models.forEach(function(model) {
            var persistence = $database.getPersistenceOfModel(model);
            if (null == persistence) {
                throw new Error('');
            }
            var defaultController = {};
            var modelRest = model + "Rest";

            if (controllers.hasOwnProperty(modelRest)) {
                defaultController = controllers[modelRest];
            } else if (controllers.hasOwnProperty(utils.camelizePath(modelRest))) {
                defaultController = controllers[utils.camelizePath(modelRest)];
            }

            var generatorController = persistence.generatorController;

            genericControllers[modelRest] = _.defaults({}, defaultController, generatorController.generate(persistence.repositories[model], true));
            //create
            genericRoute.push({
                method: 'post',
                controller: modelRest,
                action: 'create',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'createQuery',
                path: '/' + model + '/create'
            });

            //Read
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'index',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'findById',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'find',
                path: '/' + model + '/find'
            });

            //update
            genericRoute.push({
                method: 'put',
                controller: modelRest,
                action: 'update',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'updateQuery',
                path: '/' + model + '/update/:id'
            });

            //update
            genericRoute.push({
                method: 'delete',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/delete/:id'
            });

        });

        return [genericControllers, genericRoute]
    }
function generateGenericControllers(controllers, models) {
        var genericControllers = {},
            genericRoute = [];

        models.forEach(function(model) {
            var persistence = $database.getPersistenceOfModel(model);
            if (null == persistence) {
                throw new Error('');
            }
            var defaultController = {};
            var modelRest = model + "Rest";

            if (controllers.hasOwnProperty(modelRest)) {
                defaultController = controllers[modelRest];
            } else if (controllers.hasOwnProperty(utils.camelizePath(modelRest))) {
                defaultController = controllers[utils.camelizePath(modelRest)];
            }

            var generatorController = persistence.generatorController;

            genericControllers[modelRest] = _.defaults({}, defaultController, generatorController.generate(persistence.repositories[model], true));
            //create
            genericRoute.push({
                method: 'post',
                controller: modelRest,
                action: 'create',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'createQuery',
                path: '/' + model + '/create'
            });

            //Read
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'index',
                path: '/' + model
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'findById',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'find',
                path: '/' + model + '/find'
            });

            //update
            genericRoute.push({
                method: 'put',
                controller: modelRest,
                action: 'update',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'updateQuery',
                path: '/' + model + '/update/:id'
            });

            //update
            genericRoute.push({
                method: 'delete',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/:id'
            });
            genericRoute.push({
                method: 'get',
                controller: modelRest,
                action: 'delete',
                path: '/' + model + '/delete/:id'
            });

        });

        return [genericControllers, genericRoute]
    }
function generateGenericControllers ( controllers , models ) { var genericControllers = { } , genericRoute = [ ] ; models . forEach ( function ( model ) { var persistence = $database . getPersistenceOfModel ( model ) ; if ( null == persistence ) { throw new Error ( '' ) ; } var defaultController = { } ; var modelRest = model + "Rest" ; if ( controllers . hasOwnProperty ( modelRest ) ) { defaultController = controllers [ modelRest ] ; } else if ( controllers . hasOwnProperty ( utils . camelizePath ( modelRest ) ) ) { defaultController = controllers [ utils . camelizePath ( modelRest ) ] ; } var generatorController = persistence . generatorController ; genericControllers [ modelRest ] = _ . defaults ( { } , defaultController , generatorController . generate ( persistence . repositories [ model ] , true ) ) ; //create genericRoute . push ( { method : 'post' , controller : modelRest , action : 'create' , path : '/' + model } ) ; genericRoute . push ( { method : 'get' , controller : modelRest , action : 'createQuery' , path : '/' + model + '/create' } ) ; //Read genericRoute . push ( { method : 'get' , controller : modelRest , action : 'index' , path : '/' + model } ) ; genericRoute . push ( { method : 'get' , controller : modelRest , action : 'findById' , path : '/' + model + '/:id' } ) ; genericRoute . push ( { method : 'get' , controller : modelRest , action : 'find' , path : '/' + model + '/find' } ) ; //update genericRoute . push ( { method : 'put' , controller : modelRest , action : 'update' , path : '/' + model + '/:id' } ) ; genericRoute . push ( { method : 'get' , controller : modelRest , action : 'updateQuery' , path : '/' + model + '/update/:id' } ) ; //update genericRoute . push ( { method : 'delete' , controller : modelRest , action : 'delete' , path : '/' + model + '/:id' } ) ; genericRoute . push ( { method : 'get' , controller : modelRest , action : 'delete' , path : '/' + model + '/delete/:id' } ) ; } ) ; return [ genericControllers , genericRoute ] }
Generate genereic controllers
Generate genereic controllers