moment.js 2.32 KB

var moment = require('moment');
module.exports = function(Moment) {

    Moment.disableRemoteMethod("create", true);
    Moment.disableRemoteMethod("upsert", true);
    Moment.disableRemoteMethod("updateAll", true);
    Moment.disableRemoteMethod("updateAttributes", false);

    Moment.disableRemoteMethod("find", true);
    Moment.disableRemoteMethod("findById", true);
    Moment.disableRemoteMethod("findOne", true);

    Moment.disableRemoteMethod("deleteById", true);

    Moment.disableRemoteMethod("confirm", true);
    Moment.disableRemoteMethod("count", true);
    Moment.disableRemoteMethod("exists", true);
    Moment.disableRemoteMethod("resetPassword", true);

    Moment.disableRemoteMethod('__count__accessTokens', false);
    Moment.disableRemoteMethod('__create__accessTokens', false);
    Moment.disableRemoteMethod('__delete__accessTokens', false);
    Moment.disableRemoteMethod('__destroyById__accessTokens', false);
    Moment.disableRemoteMethod('__findById__accessTokens', false);
    Moment.disableRemoteMethod('__get__accessTokens', false);
    Moment.disableRemoteMethod('__updateById__accessTokens', false);

    Moment.disableRemoteMethod('create', true);                // Removes (POST) /products
    Moment.disableRemoteMethod('upsert', true);                // Removes (PUT) /products
    Moment.disableRemoteMethod('deleteById', true);            // Removes (DELETE) /products/:id
    Moment.disableRemoteMethod("updateAll", true);               // Removes (POST) /products/update
    Moment.disableRemoteMethod("updateAttributes", false);       // Removes (PUT) /products/:id
    Moment.disableRemoteMethod('createChangeStream', true);    // removes (GET|POST) /products/change-stream


    Moment.Moment = function(cb){
        var this_time = {
            "docs":"http://momentjs.com/docs/",
            "default": moment().format(),
            "DD-MM-YYYY":moment().format("DD-MM-YYYY"),
            "HH:MM:SS":moment().format("HH:mm:ss"),
            "DDMMYYYY":moment().format("DDMMYYYY"),
            "DD-MM-YYYY HH:II::SS":moment().format("DD-MM-YYYY HH:mm:ss"),
            "YYYYMMDD-HHmmssSSS":moment().format("YYYYMMDD-HHmmssSSS")
        };
        cb(null,this_time);

    };
    Moment.remoteMethod('Moment',{
        http:{path:'/Moment',verb:'get'},
        returns: {arg: 'data', type: 'object', root: true}
    })

};