File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 11module . exports = function ( app , options ) {
2+ var debug = options . debug ;
23 //turn off strong remoting rest error handler so that we can catch all errors
34 //here
45 //TODO: need to wait until PR is accepted
@@ -15,7 +16,7 @@ module.exports = function (app, options) {
1516 function JSONAPIErrorHandler ( err , req , res , next ) {
1617 res . set ( 'Content-Type' , 'application/vnd.api+json' ) ;
1718 var status = err . status || err . statusCode || 500 ;
18-
19+ debug ( err ) ;
1920 res . status ( status ) . send ( {
2021 errors : [ {
2122 status : status ,
Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ var _ = require ( 'lodash' ) ;
34var headers = require ( './headers' ) ;
45var patch = require ( './patch' ) ;
56var serialize = require ( './serialize' ) ;
@@ -8,12 +9,22 @@ var removeRemoteMethods = require('./removeRemoteMethods');
89var create = require ( './create' ) ;
910var update = require ( './update' ) ;
1011var errors = require ( './errors' ) ;
12+ var debug = require ( 'debug' ) ( 'loopback-component-jsonapi' ) ;
1113
1214module . exports = function ( app , options ) {
13- if ( ! options || ! options . restApiRoot ) {
14- options = { restApiRoot : '/api' } ;
15- }
15+ var defaultOptions = {
16+ restApiRoot : '/api' ,
17+ enable : true
18+ } ;
19+ options = options || { } ;
20+ options = _ . defaults ( options , defaultOptions ) ;
1621
22+ if ( ! options . enable ) {
23+ debug ( 'Disabled' ) ;
24+ return ;
25+ }
26+ debug ( 'Started' ) ;
27+ options . debug = debug ;
1728 headers ( app , options ) ;
1829 removeRemoteMethods ( app , options ) ;
1930 patch ( app , options ) ;
Original file line number Diff line number Diff line change 2626 "homepage" : " https://github.com/digitalsadhu/loopback-component-jsonapi#readme" ,
2727 "dependencies" : {
2828 "body-parser" : " ^1.14.1" ,
29+ "debug" : " ^2.2.0" ,
2930 "inflection" : " ^1.7.2" ,
30- "jsonapi-serializer" : " ^2.0.2"
31+ "jsonapi-serializer" : " ^2.0.2" ,
32+ "lodash" : " ^3.10.1"
3133 },
3234 "devDependencies" : {
3335 "babel-eslint" : " ^4.1.3" ,
You can’t perform that action at this time.
0 commit comments