Socket
Socket
Sign inDemoInstall

micro-compress

Package Overview
Dependencies
12
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    micro-compress

Compression for HTTP microservices built with Micro


Version published
Weekly downloads
20K
decreased by-1.49%
Maintainers
1
Install size
417 kB
Created
Weekly downloads
 

Changelog

Source

1.0.0 (2016-09-22)

Features

  • first commit (3e6b5e4)

Readme

Source

micro-compress

Build status NPM version XO code style

Compression for HTTP microservices built with Micro

Installation

Install micro-compress using npm:

npm install --save micro-compress

Usage

Module usage

Just wrap your Micro HTTP microservice with this module:

const {send, json} = require('micro');
const compress = require('micro-compress');

module.exports = compress(async (req, res) => {
	const body = await json(req);
	send(res, 200, body);
});

Options for the compression module are passed as the first parameter:

const {Z_BEST_COMPRESSION} = require('zlib');
const {send, json} = require('micro');
const compress = require('micro-compress');

module.exports = compress({level: Z_BEST_COMPRESSION}, async (req, res) => {
 const body = await json(req);
 send(res, 200, body);
});

API

compress(opts, fn)

NameTypeDescription
optsobjectOptional. Options passed to compression
fnfunctionThe request handler to wrap

For available options see compression's options.

License

MIT © Joakim Carlstein

Keywords

FAQs

Last updated on 22 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc