All Projects → alixaxel → lambdafs

alixaxel / lambdafs

Licence: MIT license
Efficient (de)compression package for AWS Lambda

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to lambdafs

pyrus-cramjam
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies
Stars: ✭ 40 (+66.67%)
Mutual labels:  gzip, decompression, brotli
Aspnetcore Request Decompression
HTTP request decompression middleware for ASP.NET Core
Stars: ✭ 51 (+112.5%)
Mutual labels:  gzip, decompression, brotli
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+595.83%)
Mutual labels:  gzip, decompression, brotli
restish
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Stars: ✭ 453 (+1787.5%)
Mutual labels:  gzip, brotli
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+10225%)
Mutual labels:  gzip, decompression
Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+13954.17%)
Mutual labels:  gzip, brotli
Connect Gzip Static
connect middleware for statically compressed files
Stars: ✭ 39 (+62.5%)
Mutual labels:  gzip, brotli
Express Security
nodejs + express security and performance boilerplate.
Stars: ✭ 37 (+54.17%)
Mutual labels:  gzip, brotli
restio
HTTP Client for Dart inspired by OkHttp
Stars: ✭ 46 (+91.67%)
Mutual labels:  gzip, brotli
Fastify Compress
Fastify compression utils
Stars: ✭ 95 (+295.83%)
Mutual labels:  gzip, brotli
Nuxt Compress
A simple static asset compression module for Nuxt that runs Gzip and Brotli compression during the build process
Stars: ✭ 61 (+154.17%)
Mutual labels:  gzip, brotli
Express Static Gzip
Simple wrapper on top of serveStatic, that allows serving pre-gzipped files as well as other types of compressions.
Stars: ✭ 119 (+395.83%)
Mutual labels:  gzip, brotli
Turbobench
Compression Benchmark
Stars: ✭ 211 (+779.17%)
Mutual labels:  gzip, brotli
pugz
Truly parallel gzip decompression
Stars: ✭ 96 (+300%)
Mutual labels:  gzip, decompression
Django Compression Middleware
Django middleware to compress responses using several algorithms.
Stars: ✭ 23 (-4.17%)
Mutual labels:  gzip, brotli
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (+504.17%)
Mutual labels:  gzip, decompression
restler
Restler is a beautiful and powerful Android app for quickly testing REST API anywhere and anytime.
Stars: ✭ 120 (+400%)
Mutual labels:  gzip, brotli
bled
Base Library for Easy Decompression
Stars: ✭ 21 (-12.5%)
Mutual labels:  gzip, decompression
Tinf
Tiny inflate library (inflate, gzip, zlib)
Stars: ✭ 57 (+137.5%)
Mutual labels:  gzip, decompression
Fusebox Angular Universal Starter
Angular Universal seed project featuring Server-Side Rendering, @fuse-box bundling, material, firebase, Jest, Nightmare, and more
Stars: ✭ 132 (+450%)
Mutual labels:  gzip, brotli

LambdaFS

lambdafs TypeScript Donate

Efficient (de)compression package for AWS Lambda, supporting Brolti, Gzip and Tarballs

Install

npm install lambdafs --save-prod

CLI

This package provides a brotli CLI command to conveniently compress files and/or folders.

npx lambdafs /path/to/compress

The resulting file will be a (potentially tarballed) Brotli compressed file, with the same base name as the source.

Due to the highest compression level, it might take a while to compress large files (100MB ~ 5 minutes).

Usage

The nodejs12.x or nodejs14.x AWS Lambda runtime is required for this package to work properly.

const lambdafs = require('lambdafs');

exports.handler = async (event, context) => {
  try {
    let file = __filename; // /var/task/index.js
    let folder = __dirname; // /var/task

    // Compressing
    let compressed = {
      file: await lambdafs.deflate(file), // /tmp/index.js.gz
      folder: await lambdafs.deflate(folder), // /tmp/task.tar.gz
    };

    // Decompressing
    let decompressed = {
      file: await lambdafs.inflate(compressed.file), // /tmp/index.js
      folder: await lambdafs.inflate(compressed.folder), // /tmp/task
    };

    return context.succeed({ file, folder, compressed, decompressed });
  } catch (error) {
    return context.fail(error);
  }
};

API

deflate(path: string): Promise<string>

Compresses a file/folder with Gzip and returns the path to the compressed (tarballed) file.

The resulting file will be saved under the default temporary directory (/tmp on AWS Lambda).

Due to costly execution time on AWS Lambda, Gzip is always used to compress files.

inflate(path: string): Promise<string>

Decompresses a (tarballed) Brotli or Gzip compressed file and returns the path to the decompressed file/folder.

The resulting file(s) will be saved under the default temporary directory (/tmp on AWS Lambda).

Supported extensions are: .br, .gz, .tar, .tar.br (and .tbr), .tar.gz (and .tgz).

For tarballs, original file modes are perserved. For any other files 0700 is assumed.

Rationale

Getting large resources onto AWS Lambda can be a challenging task due to the deployment package size limit:

Limit Context
50 MB Zipped, for direct uploads.
250 MB Unzipped, S3 and layers.

For this reason, it's important to achieve a very high compression ratio as well as fast decompression times.

This is where the Brotli algorithm comes in:

Brotli Benchmarks

It allows us to get the best compression ratio and fast decompression times (at the expense of a slow compression).

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].