@@ -31,17 +31,16 @@ pluginJsonApi.errorHandler = function errorHandler (request, reply, error) {
3131 data : request . data
3232 } )
3333
34- return reply ( Boom . internal ( error ) )
34+ return Boom . internal ( error )
3535}
3636
3737pluginJsonApi . alsoMakeItSo = function alsoMakeItSo ( request , reply ) {
3838 // eslint-disable-line consistent-return
39-
4039 try {
4140 // If there was no error and it's not one of our ignoredPaths or ignored status codes, jsonapi it
4241 if ( request . response . isBoom || _ . includes ( ignorePaths , _ . get ( request , 'route.path' ) ) || _ . includes ( ignoreStatusCodes , request . response . statusCode ) ) {
4342 // return early
44- return reply . continue ( )
43+ return reply . continue
4544 }
4645
4746 // Make the response a bit more accessible
@@ -55,7 +54,7 @@ pluginJsonApi.alsoMakeItSo = function alsoMakeItSo (request, reply) {
5554 var resources = result [ request . route . settings . bind . resourceName ]
5655 if ( ! resources ) {
5756 // no resources, return early
58- return reply . continue ( )
57+ return reply . continue
5958 }
6059
6160 var stateObject = {
@@ -72,19 +71,18 @@ pluginJsonApi.alsoMakeItSo = function alsoMakeItSo (request, reply) {
7271 * getResources() - get the resources
7372 * resolveLinkedData() - resolve the sub resources which we have collected previously
7473 */
75- utilities . collectIncludes ( stateObject )
74+ return utilities . collectIncludes ( stateObject )
7675 . then ( utilities . collectProxyableValues )
7776 . then ( utilities . getSubResources )
7877 . then ( utilities . getResources )
7978 . then ( utilities . resolveLinkedData )
8079 . then ( function ( ) {
8180 // all done
82- return reply . continue ( )
81+ return reply . continue
8382 } )
8483 . fail ( function ( error ) {
8584 return pluginJsonApi . errorHandler ( request , reply , error )
8685 } )
87- . done ( )
8886 } catch ( error ) {
8987 return pluginJsonApi . errorHandler ( request , reply , error )
9088 }
@@ -94,10 +92,9 @@ pluginJsonApi.alsoMakeItSo = function alsoMakeItSo (request, reply) {
9492* Registers the plugin when the hapi server bootstraps - follows the convention for Hapi.js plugins
9593* @param {object } server - the hapi plugin object
9694* @param {object } options - any initial options needed to set up the plugin
97- * @param {function } next - the next plugin to be set up
9895* @returns {undefined } Nothing - calls the next plugin
9996*/
100- pluginJsonApi . register = function ( server , options , next ) {
97+ const register = function ( server , options ) {
10198 function makeItSo ( request , reply ) {
10299 return pluginJsonApi . alsoMakeItSo ( request , reply )
103100 }
@@ -109,10 +106,14 @@ pluginJsonApi.register = function (server, options, next) {
109106 if ( process . env . NODE_ENV === 'test' ) {
110107 server . expose ( 'makeItSo' , makeItSo )
111108 }
112-
113- next ( )
114109}
115110
116- pluginJsonApi . register . attributes = {
117- pkg : require ( '../package.json' )
111+ const pkg = require ( '../package.json' )
112+ const { version, name} = pkg
113+
114+ pluginJsonApi . plugin = {
115+ register,
116+ name,
117+ version,
118+ pkg
118119}
0 commit comments