How to use the restitute.controller.get function in restitute

To help you get started, we’ve selected a few restitute examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gadael / gadael / rest / user / settings.js View on Github external
'use strict';



var ctrlFactory = require('restitute').controller;


function getController() {
    ctrlFactory.get.call(this, '/rest/user/settings');

    this.controllerAction = function() {
        this.jsonService(this.service('user/settings/get', { user: this.req.user.id }));
    };
}
getController.prototype = new ctrlFactory.get();





function updateController() {
    ctrlFactory.update.call(this, '/rest/user/settings');

    var controller = this;
    this.controllerAction = function() {

        // since service is query independant, we have to give
        // the additional parameter

        controller.jsonService(
            controller.service('user/settings/save', {
github gadael / gadael / rest / anonymous / invitation.js View on Github external
.select('name')
                .exec()
                .then(calendars => {
                    invitation.scheduleCalendars = calendars;
                    return invitation;
                });
            });
        })
        .then(invitation => {
            controller.res.statusCode = 200;
            controller.res.json(invitation);
        })
        .catch(err => controller.error(err.message));
    };
}
getController.prototype = new ctrlFactory.get();




/**
 * A POST on anonymous/invitation create the user
 *
 */
function createController() {
    ctrlFactory.create.call(this, '/rest/anonymous/invitation');
    var controller = this;


    this.controllerAction = function() {

        const gt = controller.req.app.utility.gettext;
github gadael / gadael / rest / admin / compulsoryleaves.js View on Github external
this.controllerAction = function() {
        this.jsonService(this.service('admin/compulsoryleaves/list'));
    };
}
listController.prototype = new ctrlFactory.list();


function getController() {
    ctrlFactory.get.call(this, '/rest/admin/compulsoryleaves/:id');

    this.controllerAction = function() {
        this.jsonService(this.service('admin/compulsoryleaves/get'));
    };
}
getController.prototype = new ctrlFactory.get();


function save() {
    this.jsonService(this.service('admin/compulsoryleaves/save', { userCreated: this.req.user }));
}

function createController() {
    ctrlFactory.create.call(this, '/rest/admin/compulsoryleaves');
    this.controllerAction = save;
}
createController.prototype = new ctrlFactory.create();

function updateController() {
    ctrlFactory.update.call(this, '/rest/admin/compulsoryleaves/:id');
    this.controllerAction = save;
}
github gadael / gadael / rest / admin / waitingrequests.js View on Github external
this.controllerAction = function() {
        this.jsonService(this.service('manager/waitingrequests/list'));
    };
}
listController.prototype = new ctrlFactory.list();


function getController() {
    ctrlFactory.get.call(this, '/rest/admin/waitingrequests/:id');

    this.controllerAction = function() {
        this.jsonService(this.service('manager/waitingrequests/get'));
    };
}
getController.prototype = new ctrlFactory.get();


/**
 * Confirm or reject a waiting request instead of a manager
 */
function updateController() {
    ctrlFactory.update.call(this, '/rest/admin/waitingrequests/:id');

    var controller = this;
    this.controllerAction = function() {
        controller.jsonService(
            controller.service('manager/waitingrequests/save')
        );
    };
}
updateController.prototype = new ctrlFactory.update();
github gadael / gadael / rest / admin / rightrenewals.js View on Github external
this.controllerAction = function() {
        this.jsonService(this.service('admin/rightrenewals/list'));
    };
}
listController.prototype = new ctrlFactory.list();


function getController() {
    ctrlFactory.get.call(this, '/rest/admin/rightrenewals/:id');

    this.controllerAction = function() {
        this.jsonService(this.service('admin/rightrenewals/get'));
    };
}
getController.prototype = new ctrlFactory.get();


function save() {
    this.jsonService(this.service('admin/rightrenewals/save'));
}

function createController() {
    ctrlFactory.create.call(this, '/rest/admin/rightrenewals');
    this.controllerAction = save;
}
createController.prototype = new ctrlFactory.create();

function updateController() {
    ctrlFactory.update.call(this, '/rest/admin/rightrenewals/:id');
    this.controllerAction = save;
}

restitute

A nodejs controller libraray to create a JSON REST service

MIT
Latest version published 5 years ago

Package Health Score

42 / 100
Full package analysis