{"id":18317933,"url":"https://github.com/idiocc/compress","last_synced_at":"2025-04-09T13:51:32.888Z","repository":{"id":57113697,"uuid":"229682436","full_name":"idiocc/compress","owner":"idiocc","description":"Compression Middleware For Goa Apps.","archived":false,"fork":false,"pushed_at":"2020-01-09T14:36:44.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-15T07:48:59.161Z","etag":null,"topics":["compress","goa","gzip","idio","middleware"],"latest_commit_sha":null,"homepage":"https://www.idio.cc","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/idiocc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-23T05:25:26.000Z","updated_at":"2020-01-09T14:36:46.000Z","dependencies_parsed_at":"2022-08-22T05:30:42.047Z","dependency_job_id":null,"html_url":"https://github.com/idiocc/compress","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":"idiocc/package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fcompress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fcompress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fcompress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fcompress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiocc","download_url":"https://codeload.github.com/idiocc/compress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054218,"owners_count":21039951,"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":["compress","goa","gzip","idio","middleware"],"created_at":"2024-11-05T18:07:55.883Z","updated_at":"2025-04-09T13:51:32.861Z","avatar_url":"https://github.com/idiocc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @goa/compress\n\n[![npm version](https://badge.fury.io/js/%40goa%2Fcompress.svg)](https://www.npmjs.com/package/@goa/compress)\n\n`@goa/compress` is Compression Middleware For Goa Apps.\n\n```sh\nyarn add @goa/compress\nnpm install @goa/compress\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`compress(config): !Middleware`](#compressconfig-compressconfig-middleware)\n  * [`CompressConfig`](#type-compressconfig)\n- [Usage Events](#usage-events)\n- [Copyright \u0026 License](#copyright--license)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/0.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport compress from '@goa/compress'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## \u003ccode\u003e\u003cins\u003ecompress\u003c/ins\u003e(\u003c/code\u003e\u003csub\u003e\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`config: !CompressConfig,`\u003cbr/\u003e\u003c/sub\u003e\u003ccode\u003e): \u003ci\u003e!Middleware\u003c/i\u003e\u003c/code\u003e\nCompression Middleware For Goa Apps.\n\n - \u003ckbd\u003e\u003cstrong\u003econfig*\u003c/strong\u003e\u003c/kbd\u003e \u003cem\u003e\u003ccode\u003e[!CompressConfig](#type-compressconfig)\u003c/code\u003e\u003c/em\u003e: The config.\n\n\u003cstrong\u003e\u003ca name=\"type-compressconfig\"\u003e`CompressConfig`\u003c/a\u003e extends \u003ca href=\"https://nodejs.org/api/zlib.html#zlib_class_options\" title=\"Each zlib-based class takes an options object. All options are optional.\"\u003e`zlib.ZlibOptions`\u003c/a\u003e\u003c/strong\u003e\n\n\n|   Name    |                Type                 |                                                          Description                                                          | Default |\n| --------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------- |\n| threshold | \u003cem\u003enumber\u003c/em\u003e                     | Minimum response size in bytes to compress.                                                                                   | `1024`  |\n| filter    | \u003cem\u003e(type?: string) =\u003e boolean\u003c/em\u003e | An optional function that checks the response content type to decide whether to compress. By default, it uses `compressible`. | -       |\n\n```js\nimport { aqt } from 'rqt'\nimport Goa from '@goa/koa'\nimport compress from '../compile'\nimport packageJson from '../package'\n\nconst goa = new Goa()\ngoa.use(compress())\ngoa.use(ctx =\u003e {\n  ctx.body = packageJson\n})\n\ngoa.listen(async function() {\n  const url = 'http://localhost:' + this.address().port\n  const { headers } = await aqt(url)\n  console.log(headers)\n  this.close()\n})\n```\n```js\n{ vary: 'Accept-Encoding',\n  'content-type': 'application/json; charset=utf-8',\n  'content-encoding': 'gzip',\n  date: 'Thu, 09 Jan 2020 14:35:12 GMT',\n  connection: 'close',\n  'transfer-encoding': 'chunked' }\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/2.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## Usage Events\n\nThis middleware integrates with [_Idio_](https://github.com/idiocc/idio) that collects middleware usage statistics to reward package maintainers. It will emit certain events to bill its usage:\n\n1. `stream`: When the compression is applied to stream.\n1. `data`: When non-stream body is compressed.\n\nThe usage is recorded via the `ctx.neoluddite` context property set by a server such as _Idio_. In future, more fine-grained usage events might appear.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/3.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## Copyright \u0026 License\n\nGNU Affero General Public License v3.0\n\nAffero GPL means that you're not allowed to use this middleware on the web unless you release the source code for your application. This is a restrictive license which has the purpose of defending Open Source work and its creators.\n\nPlease refer to the [Idio license agreement](https://github.com/idiocc/idio#copyright--license) for more info on dual-licensing. You're allowed to use this middleware without disclosing the source code if you sign up on [neoluddite.dev](https://neoluddite.dev) package reward scheme.\n\n[Original work](https://github.com/koajs/compress) by _Jonathan Ong_ under MIT license found in [COPYING](COPYING).\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://artd.eco\"\u003e\n        \u003cimg width=\"100\" src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\"\n          alt=\"Art Deco\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e© \u003ca href=\"https://artd.eco\"\u003eArt Deco\u003c/a\u003e for \u003ca href=\"https://idio.cc\"\u003eIdio\u003c/a\u003e 2020\u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://idio.cc\"\u003e\n        \u003cimg src=\"https://avatars3.githubusercontent.com/u/40834161?s=100\" width=\"100\" alt=\"Idio\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\"\u003e\n        \u003cimg width=\"100\" src=\"https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg\"\n          alt=\"Tech Nation Visa\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\u003ca href=\"https://www.technation.sucks\"\u003eTech Nation Visa Sucks\u003c/a\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/-1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fcompress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiocc%2Fcompress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fcompress/lists"}