### Install brok package Source: https://github.com/kanongil/brok/blob/master/README.md Installs the brok npm package using npm. This is the first step to integrate Brotli compression into a hapi.js application. ```sh npm install brok ``` -------------------------------- ### Register brok plugin with custom quality Source: https://github.com/kanongil/brok/blob/master/README.md Demonstrates how to register the brok plugin with a hapi.js server, setting a custom Brotli compression quality. It shows the necessary imports and server setup. ```javascript 'use strict'; const Hapi = require('@hapi/hapi'); const Brok = require('brok'); const server = new Hapi.Server({ port: 3000, compression: { minBytes: 1 } }); const provision = async () => { server.route({ method: 'GET', path: '/fetch', handler() { return 'ok'; } }); await server.register({ plugin: Brok, options: { compress: { quality: 3 } } }); await server.start(); console.log('Server running at:', server.info.uri); }; provision(); ``` -------------------------------- ### Run Tests and Check Coverage Source: https://github.com/kanongil/brok/blob/master/CONTRIBUTING.md Execute the project's test suite and generate a code coverage report. This command is essential for verifying code changes and ensuring adherence to the 100% coverage requirement before submitting contributions. ```bash npm test ``` -------------------------------- ### Configure route-specific brotli compression Source: https://github.com/kanongil/brok/blob/master/README.md Shows how to apply Brotli compression settings, like compression mode, to individual routes within a hapi.js application. This allows fine-grained control over compression behavior. ```javascript server.route({ method: 'GET', path: '/text', options: { handler() { return 'hello!'; }, compression: { br: { mode: 'text' } } } }); ``` -------------------------------- ### brok Registration Options Source: https://github.com/kanongil/brok/blob/master/README.md Details the options available when registering the brok plugin with a hapi.js server. These options control Brotli compression and decompression behavior. ```APIDOC brok Plugin Registration Options: - compress: Compression settings. Set to `false` to disable response compression using brotli. - quality: Used to adjust compression speed vs quality from 0 to 11. Defaults to `5`. - mode: Compression mode. Available values: - 'generic': Default compression mode. Default value. - 'text': Optimize for UTF-8 formatted text input. - decompress: If `true`, also register the encoding for decompressing incoming payloads. Defaults to `false`. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.