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

fastify-compression

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-compression - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

24

index.js

@@ -6,3 +6,2 @@ 'use strict';

const zlib = require('zlib');
const serialize = require('fastify/lib/validation').serialize;

@@ -22,12 +21,9 @@ function compressionPlugin(fastify, opts, next) {

function _serialize(payload) {
const _payload = serialize(reply.context, payload, reply.res.statusCode)
if(_payload.length >= threshold) {
setVaryHeader(reply);
reply.header('Content-Encoding', method);
return zlib.gzipSync(_payload);
}
return _payload
let _payload = reply.serialize(payload)
if(_payload.length >= threshold) {
setVaryHeader(reply);
reply.header('Content-Encoding', method);
_payload = zlib.gzipSync(_payload);
}
reply.serializer(_serialize);
reply.serializer(getSerializer(_payload));
} else if(payload.length >= threshold) {

@@ -45,2 +41,8 @@ setVaryHeader(reply);

function getSerializer(_payload) {
return function _serialize(payload) {
return _payload
};
}
function getMethod(acceptEncoding) {

@@ -84,2 +86,2 @@ const encodings = (acceptEncoding || '').split(', ');

exports = module.exports = fastifyPlugin(compressionPlugin, '>=0.33.0');
exports = module.exports = fastifyPlugin(compressionPlugin, '>=0.34.0');
{
"name": "fastify-compression",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "tap test/*",
"unit": "tap test/*",
"test": "npm run lint && npm run unit",
"lint": "./node_modules/eslint/bin/eslint.js index.js lib/*",
"coveralls": "npm run test -- --cov",
"coveralls": "npm run unit -- --cov",
"coverage-report": "npm run coveralls && tap --coverage-report=lcov"

@@ -31,3 +32,3 @@ },

"eslint": "^4.10.0",
"fastify": "^0.33.0",
"fastify": "^0.34.0",
"request": "^2.83.0",

@@ -34,0 +35,0 @@ "tap": "^10.7.2"

# fastify-compression
[![Greenkeeper badge](https://badges.greenkeeper.io/SerayaEryn/fastify-compression.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/SerayaEryn/fastify-compression.svg?branch=master)](https://travis-ci.org/SerayaEryn/fastify-compression)

@@ -4,0 +5,0 @@ [![Coverage Status](https://coveralls.io/repos/github/SerayaEryn/fastify-compression/badge.svg?branch=master)](https://coveralls.io/github/SerayaEryn/fastify-compression?branch=master)

Sorry, the diff of this file is not supported yet

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