Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micro-compress

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro-compress

Compression for HTTP microservices built with Micro

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
increased by22.74%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 22 Sep 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc