Skip to content

Commit 661becc

Browse files
committed
Update
1 parent 428f987 commit 661becc

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ In your loopback project:
3636
```json
3737
{
3838
"loopback-component-jsonapi": {
39-
"restApiRoot": "/api"
39+
"restApiRoot": "/api",
40+
"enable": true,
41+
"keyForAttribute": "dash-case",
42+
"keyForType": "dash-case",
43+
"keyForRelation": "dash-case"
4044
}
4145
}
4246
```

lib/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ var debug = require('debug')('loopback-component-jsonapi');
1414
module.exports = function (app, options) {
1515
var defaultOptions = {
1616
restApiRoot: '/api',
17-
enable: true
17+
enable: true,
18+
keyForAttribute: 'dash-case',
19+
keyForType: 'dash-case',
20+
keyForRelation: 'dash-case'
1821
};
1922
options = options || {};
2023
options = _.defaults(options, defaultOptions);

lib/serialize.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
var Serializer = require('./serializer');
44
var utils = require('./utils');
5+
var _ = require('lodash');
56

6-
module.exports = function (app, options) {
7+
module.exports = function (app, defaults) {
78
var remotes = app.remotes();
89

910
remotes.after('**', function (ctx, next) {
@@ -78,6 +79,7 @@ module.exports = function (app, options) {
7879
}
7980
}
8081
};
82+
options = _.defaults(options, defaults);
8183
var relations = {};
8284
if (this.definition) {
8385
relations = this.definition.settings.relations;

lib/serializer.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ var _ = require('lodash');
22
var inflection = require('inflection');
33

44
module.exports = function Serializer (type, data, relations, options) {
5-
var defaults = {
6-
keyForAttribute: 'dash-case',
7-
keyForType: 'dash-case',
8-
keyForRelation: 'dash-case'
9-
};
10-
options = _.defaults(options, defaults);
5+
116
if (options.topLevelLinks.self.match(/\/relationships\//)) {
127
options.topLevelLinks.related = options.topLevelLinks.self.replace('/relationships/', '/');
138
options.isRelationshipRequest = true;

0 commit comments

Comments
 (0)