1.5.2 • Published 7 years ago

loopback-remote-routing v1.5.2

Weekly downloads
193
License
ISC
Repository
github
Last release
7 years ago

loopback-remote-routing

Circle CI

Easily disable remote methods.

##Features

  • selectively disable remote methods created by relations, defined by code or in definition
  • selectively disable remote methods created by scopes , defined by code or in definition
  • easily disable custom remote methods, currently works only when use RemoteRouting directly in js file
  • support loopback-component-storage specific methods
  • use as mixin
  • support for loopback@3.x

##Installation

npm install loopback-remote-routing --save

##How to use

###use directly

// common/models/color.js
var RemoteRouting = require('loopback-remote-routing');

module.exports = function(Color) {
  // use only to expose specified remote methods
  // symbol @ denotes static method
  // scope methods are static method
  // custom remote method  also need to follow the naming convention
  RemoteRouting(Color, {only: [
      '@find',
      '@findById',
      'updateAttributes',
      '@customRemotemethod',
      'customRemotemethodOnPrototype'
  ]})

  //use except to expose all remote methods except specified ones
  RemoteRouting(Color, {except: [
      '@create',
      '@find'
  ]}

  //disable all remote methods omitting options

  RemoteRouting(Color)

}

use 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"
        ]
      }
    }
  }

##Options

optiontypedescriptionrequired
onlyStringexpose specified remote methodsfalse
exceptStringexpose all remote methods except specified onesfalse

You can only use options.only or options.except, do not use them together.

If you don't know the relation methods name , you can read the doc : http://loopback.io/doc/en/lb3/Exposing-models-over-REST.html

##TODO

  • allow disable custom remote methods
  • disable alias remote methods, such as upert, patchOrCreate
1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.2

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago