Skip to content

Commit 7b6cb26

Browse files
committed
Add option to disable hiding irrelevant methods
1 parent 78ce8e7 commit 7b6cb26

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ Example:
7373
{"methods": "find"},
7474
{"model": "post", "methods": "find"},
7575
{"model": "person", "methods": ["find", "create"]}
76-
]
76+
],
77+
"hideIrrelevantMethods": true
7778
}
7879
}
7980
```
@@ -121,6 +122,21 @@ all models:
121122
Type: array
122123
Default: null
123124

125+
### hideIrrelevantMethods
126+
By default, loopback-component-jsonapi disables a number of methods from each endpoint
127+
that are not jsonapi relevant. These methods are:
128+
- upsert
129+
- exists
130+
- findOne
131+
- count
132+
- createChangeStream
133+
- updateAll
134+
You can use this option to reenable these methods.
135+
Please note, these methods will not be modified by the component and so their output
136+
will not be in a jsonapi compliant format.
137+
Type: boolean
138+
Default: true
139+
124140
## Debugging
125141
You can enable debug logging by setting an environment variable:
126142
DEBUG=loopback-component-jsonapi

lib/removeRemoteMethods.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ module.exports = function (app, options) {
55
//does not support.
66
var isStatic = true;
77

8-
Object.keys(models).forEach(function (model) {
9-
['upsert', 'exists', 'findOne', 'count', 'createChangeStream', 'updateAll'].forEach(function (method) {
10-
models[model].disableRemoteMethod(method, isStatic);
8+
if (options.hideIrrelevantMethods !== false) {
9+
Object.keys(models).forEach(function (model) {
10+
['upsert', 'exists', 'findOne', 'count', 'createChangeStream', 'updateAll'].forEach(function (method) {
11+
models[model].disableRemoteMethod(method, isStatic);
12+
});
1113
});
12-
});
14+
}
1315
};

0 commit comments

Comments
 (0)