Skip to content

Set the totalCount by adding the totalCount to the request object - Use request.plugins #53

@BrandonNoad

Description

@BrandonNoad

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions