{"id":22505790,"url":"https://github.com/kanongil/brok","last_synced_at":"2025-08-03T12:32:03.799Z","repository":{"id":51262951,"uuid":"66275308","full_name":"kanongil/brok","owner":"kanongil","description":"Brotli encoder and decoder for hapi.js","archived":false,"fork":false,"pushed_at":"2024-03-25T09:35:16.000Z","size":95,"stargazers_count":15,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-14T05:57:01.328Z","etag":null,"topics":["brotli","brotli-encoder","hapi","hapi-plugin","javascript","node"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanongil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-22T13:30:48.000Z","updated_at":"2024-06-18T22:53:29.123Z","dependencies_parsed_at":"2024-03-25T10:54:25.694Z","dependency_job_id":null,"html_url":"https://github.com/kanongil/brok","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanongil%2Fbrok","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanongil%2Fbrok/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanongil%2Fbrok/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanongil%2Fbrok/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanongil","download_url":"https://codeload.github.com/kanongil/brok/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228543607,"owners_count":17934524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brotli","brotli-encoder","hapi","hapi-plugin","javascript","node"],"created_at":"2024-12-07T00:33:29.752Z","updated_at":"2024-12-07T00:33:30.234Z","avatar_url":"https://github.com/kanongil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# brok\n\nBrotli encoder and decoder for hapi.js.\n\n[![Node.js CI](https://github.com/kanongil/brok/actions/workflows/ci.yaml/badge.svg)](https://github.com/kanongil/brok/actions/workflows/ci.yaml)\n\nLead Maintainer - [Gil Pedersen](https://github.com/kanongil)\n\n## Install\n\n```sh\nnpm install brok\n```\n\n## Example\n\n### Registration\n\nRegistration with custom quality default:\n\n```js\n'use strict';\n\nconst Hapi = require('@hapi/hapi');\nconst Brok = require('brok');\n\nconst server = new Hapi.Server({ port: 3000, compression: { minBytes: 1 } });\n\nconst provision = async () =\u003e {\n\n    server.route({\n        method: 'GET',\n        path: '/fetch',\n        handler() {\n\n            return 'ok';\n        }\n    });\n\n    await server.register({\n        plugin: Brok,\n        options: {\n            compress: { quality: 3 }\n        }\n    });\n\n    await server.start();\n\n    console.log('Server running at:', server.info.uri);\n};\n\nprovision();\n```\n\n## Usage\n\nOnce registered, **brok** enables the server to negotiate and handle the `\"br\"` encoding for\ncompressible responses and uploads.\n\n### Registration options\n\n**brok** accepts the following registration options:\n\n  - `compress` - compression settings.\n    Set to `false` to disable response compression using brotli.\n      - `quality` - used to adjust compression speed vs quality from 0 to 11.\n        Defaults to `5`.\n      - `mode` - compression mode.\n        Available values:\n        - `'generic'` - default compression mode. Default value.\n        - `'text'` - optimize for UTF-8 formatted text input.\n  - `decompress` - if `true`, also register the encoding for decompressing incoming payloads.\n    Defaults to `false`.\n\n### Compression options\n\nRoute specific settings can be set using `br` object in the `compression` config. Eg.\n\n```js\nserver.route({\n    method: 'GET',\n    path: '/text',\n    options: {\n        handler() {\n\n            return 'hello!';\n        },\n        compression: {\n            br: { mode: 'text' }\n        }\n    }\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanongil%2Fbrok","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanongil%2Fbrok","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanongil%2Fbrok/lists"}