Hi all,
once before, if we want to disable remote methods, we have to write a bunch of statements like this:
User.disableRemoteMethod('create', true);
User.disableRemoteMethod('__get__items', false);
User.disableRemoteMethod('findById', true);
using loopback-remote-routing, what you have to do, is simply passing some options
var RemoteRouting = require('loopback-remote-routing');
//use options.only to expose specifed remote methods;
//in this case only create, findById, __get__items will be exposed
RemoteRouting(User, {only: [
'@create',
'@findById',
'__get__items'
]}
//use options.except to expose all remote methods except ones specified;
// in this case, findById, create, __get__items, will be disabled
RemoteRouting(User, {except: [
'@create',
'@findById',
'__get__items'
]}
it can also be used as a mixin:
Add the mixins property to your server/model-config.json like the following:
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"../node_modules/loopback-remote-routing",
"../common/mixins"
]
}
}
To use with your Models add the mixins attribute to the definition object of your model config.
{
"name": "Color",
"properties": {
"name": {
"type": "string",
}
},
"mixins": {
"RemoteRouting" : {
"only": [
"@find"
]
}
}
}
welcome to open issues if you have any questions