hapi-pagination
hapi-pagination copied to clipboard
Set the totalCount by adding the totalCount to the request object - Use request.plugins
In the current implementation, the totalCount is set directly on the request object:
request.totalCount = 10;
reply(results);
Hapi recommends that you use the 'plugins' property to store plugin-specific state. From the docs:
Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state.
So it would be better to do:
request.plugins['hapi-pagination'] = {
totalCount: 10
};
reply(results);
Although this would be a breaking change, it is a safe place to store plugin data without potential conflicts with the framework.