Loopback mixin to set what fields can be received in request.
npm install loopback-allowed-properties-mixinloopback-allowed-properties-mixin
===============
 

Loopback mixin to set what fields can be written in a request.
npm install loopback-allowed-properties-mixin --save
Add the mixins property to your server/model-config.json:
``json`
{
"_meta": {
"sources": [
"loopback/common/models",
"loopback/server/models",
"../common/models",
"./models"
],
"mixins": [
"loopback/common/mixins",
"../node_modules/loopback-allowed-properties-mixin",
"../common/mixins"
]
}
}
Add mixin params in model definition. Example:
``
{
"name": "Person",
"properties": {
"name": "string",
"email": "string",
"status": "string",
},
"mixins": {
"AllowedProperties": {
"create": [
"name",
"email"
],
"prototype.patchAttributes": [
"name"
],
"setStatus": [
"status"
]
}
}
}
In the above definition, create method will only recieve the request body with properties name and email, prototype.patchAttributes method will only recieve the request body with name attribute and finally setStatus method will only recieve status attribute in the body request.
If you have any kind of trouble with it, just let me now by raising an issue on the GitHub issue tracker here:
https://github.com/arondn2/loopback-allowed-properties-mixin/issues
Also, you can report the orthographic errors in the READMEs files or comments. Sorry for that, English is not my main language.
npm test or npm run cover`