npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goa/compress

v1.2.1

Published

Compression Middleware For Goa Apps.

Downloads

17

Readme

@goa/compress

npm version

@goa/compress is Compression Middleware For Goa Apps.

yarn add @goa/compress
npm install @goa/compress

Table Of Contents

API

The package is available by importing its default function:

import compress from '@goa/compress'

compress(  config: !CompressConfig,): !Middleware

Compression Middleware For Goa Apps.

CompressConfig extends zlib.ZlibOptions

| Name | Type | Description | Default | | --------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------- | | threshold | number | Minimum response size in bytes to compress. | 1024 | | filter | (type?: string) => boolean | An optional function that checks the response content type to decide whether to compress. By default, it uses compressible. | - |

import { aqt } from 'rqt'
import Goa from '@goa/koa'
import compress from '../compile'
import packageJson from '../package'

const goa = new Goa()
goa.use(compress())
goa.use(ctx => {
  ctx.body = packageJson
})

goa.listen(async function() {
  const url = 'http://localhost:' + this.address().port
  const { headers } = await aqt(url)
  console.log(headers)
  this.close()
})
{ vary: 'Accept-Encoding',
  'content-type': 'application/json; charset=utf-8',
  'content-encoding': 'gzip',
  date: 'Thu, 09 Jan 2020 14:35:12 GMT',
  connection: 'close',
  'transfer-encoding': 'chunked' }

Usage Events

This middleware integrates with Idio that collects middleware usage statistics to reward package maintainers. It will emit certain events to bill its usage:

  1. stream: When the compression is applied to stream.
  2. data: When non-stream body is compressed.

The 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.

Copyright & License

GNU Affero General Public License v3.0

Affero 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.

Please refer to the Idio license agreement 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 package reward scheme.

Original work by Jonathan Ong under MIT license found in COPYING.