{"id":13725469,"url":"https://github.com/tuananh/kompression","last_synced_at":"2025-05-07T20:32:31.757Z","repository":{"id":65339687,"uuid":"111133582","full_name":"tuananh/kompression","owner":"tuananh","description":"This is a fork of koa-compress with support for brotli compression","archived":true,"fork":false,"pushed_at":"2020-07-16T04:34:48.000Z","size":256,"stargazers_count":8,"open_issues_count":2,"forks_count":4,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2024-11-12T23:35:44.712Z","etag":null,"topics":["brotli","compression","gzip","koa","middleware"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuananh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-17T17:47:18.000Z","updated_at":"2023-01-28T13:41:59.000Z","dependencies_parsed_at":"2023-01-18T02:50:11.357Z","dependency_job_id":null,"html_url":"https://github.com/tuananh/kompression","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuananh%2Fkompression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuananh%2Fkompression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuananh%2Fkompression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuananh%2Fkompression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuananh","download_url":"https://codeload.github.com/tuananh/kompression/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645381,"owners_count":17346139,"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","compression","gzip","koa","middleware"],"created_at":"2024-08-03T01:02:24.265Z","updated_at":"2024-11-14T15:31:21.291Z","avatar_url":"https://github.com/tuananh.png","language":"JavaScript","readme":"# Kompression\n\n[![npm](https://img.shields.io/npm/v/kompression.svg)](https://npm.im/kompression)\n[![Build Status](https://dev.azure.com/me0499/kompresssion/_apis/build/status/tuananh.kompression?branchName=develop)](https://dev.azure.com/me0499/kompresssion/_build/latest?definitionId=2\u0026branchName=develop)\n\nThis is a fork of [koa-compress](https://github.com/koajs/compress) with support for brotli compression.\n\nBecause `zlib` and `iltorb` options doesn't have much in common so including support for brotli\nwould be a breaking change.\n\nI'm trimming down the available options in this package down to just `filter` and `threshold`.\n\n## Example\n\n```js\nconst compress = require('kompression')\nconst Koa = require('koa')\n\nconst app = new Koa()\napp.use(\n    compress({\n        filter: function(content_type) {\n            return /text/i.test(content_type)\n        },\n        threshold: 2048\n    })\n)\n```\n\n## Options\n\n### filter\n\nAn optional function that checks the response content type to decide whether to compress.\nBy default, it uses [compressible](https://github.com/expressjs/compressible).\n\n### threshold\n\nMinimum response size in bytes to compress.\nDefault `1024` bytes or `1kb`.\n\n## Manually turning compression on and off\n\nYou can always enable compression by setting `this.compress = true`.\nYou can always disable compression by setting `this.compress = false`.\nThis bypasses the filter check.\n\n```js\napp.use((ctx, next) =\u003e {\n    ctx.compress = true\n    ctx.body = fs.createReadStream(file)\n})\n```\n","funding_links":[],"categories":["仓库","JavaScript"],"sub_categories":["中间件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuananh%2Fkompression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuananh%2Fkompression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuananh%2Fkompression/lists"}