0.0.1 • Published 6 years ago

loopback-disable-method-mixin v0.0.1

Weekly downloads
13
License
MIT
Repository
github
Last release
6 years ago

loopback-disable-method-mixin

A mixin to disable or expose a list of properties in a model.

based on

INSTALL

npm install --save loopback-disable-method-mixin
you can enable mixin by editing server.js:

In your server/server.js file add the following line before the boot(app, __dirname); line.

...
var app = module.exports = loopback();
...
// Add Disable Method Mixin to loopback
require('loopback-disable-method-mixin')(app);

boot(app, __dirname, function(err) {
  'use strict';
  if (err) throw err;

  // start the server if `$ node server.js`
  if (require.main === module)
    app.start();
});

CONFIG

To use with your Models add the mixins attribute to the definition object of your model config.

{
  "name": "player",
  "mixins": {
    "DisableMethods": {
      "expose": ["find", "findById"]
    }
  },
  "properties": {
    "name": "string",
    "type": "string"
  }
}

OR

{
  "name": "player",
  "mixins": {
    "DisableMethods": {
      "hide": ["find"]
    }
  },
  "properties": {
    "name": "string",
    "type": "string"
  }
}

LICENSE

MIT