It can be done. Here is the documentation https://github.com/hapijs/good/blob/master/API.md#stream-transforms-using-plugin-configs
Hapi Route Configuration
var routeConfig = { plugins: { good: { suppressResponseEvent: true } } }; server.route({ method: '*', path: '/suscribe/{path*}', handler: function(req, rep){ rep("OK!"); }, config: routeConfig });
Create a custom filter for the good . You will need to create a new npm package. In this example, we will call it a good filter. Follow the architecture https://github.com/hapijs/good-squeeze/ The main file (index.js) contains:
'use strict'; module.exports = { Filter: require("./filter.js") };
This package should be available when downloading good . The following code goes into filter.js in a good filter package.
'use strict'; const Stream = require('stream'); class Filter extends Stream.Transform { constructor(options) { options = Object.assign({}, options, { objectMode: true }); super(options); } _transform(data, enc, next) { if (data.event === 'response' && data.config.suppressResponseEvent === true) { return next(); } return next(null, data); } } module.exports = Filter;
Finally, add a filter to a good configuration.
const options = { ops: { interval: 1000 }, reporters: { myConsoleReporter: [{ module: 'good-squeeze', name: 'Squeeze', args: [{ log: '*', response: '*' }] }, { module: 'good-filter', name: 'Filter', args: [{ log: '*', response: '*' }] }, { module: 'good-console' }, 'stdout'] } };