{"id":16294220,"url":"https://github.com/alixaxel/lambdafs","last_synced_at":"2025-03-16T13:31:35.518Z","repository":{"id":57148040,"uuid":"208430674","full_name":"alixaxel/lambdafs","owner":"alixaxel","description":"Efficient (de)compression package for AWS Lambda","archived":false,"fork":false,"pushed_at":"2021-12-24T16:46:21.000Z","size":409,"stargazers_count":26,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-16T02:47:38.328Z","etag":null,"topics":["aws","aws-lambda","brotli","decompression","gzip","serverless"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alixaxel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"alixaxel"}},"created_at":"2019-09-14T11:27:45.000Z","updated_at":"2025-03-13T03:47:17.000Z","dependencies_parsed_at":"2022-09-06T17:01:35.362Z","dependency_job_id":null,"html_url":"https://github.com/alixaxel/lambdafs","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixaxel%2Flambdafs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixaxel%2Flambdafs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixaxel%2Flambdafs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alixaxel%2Flambdafs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alixaxel","download_url":"https://codeload.github.com/alixaxel/lambdafs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818167,"owners_count":20352629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-lambda","brotli","decompression","gzip","serverless"],"created_at":"2024-10-10T20:14:36.268Z","updated_at":"2025-03-16T13:31:35.226Z","avatar_url":"https://github.com/alixaxel.png","language":"TypeScript","funding_links":["https://github.com/sponsors/alixaxel","https://paypal.me/alixaxel"],"categories":[],"sub_categories":[],"readme":"# LambdaFS\n\n[![lambdafs](https://img.shields.io/npm/v/lambdafs.svg?style=for-the-badge)](https://www.npmjs.com/package/lambdafs)\n[![TypeScript](https://img.shields.io/npm/types/chrome-aws-lambda?style=for-the-badge)](https://www.typescriptlang.org/dt/search?search=lambdafs)\n[![Donate](https://img.shields.io/badge/donate-paypal-orange.svg?style=for-the-badge)](https://paypal.me/alixaxel)\n\nEfficient (de)compression package for AWS Lambda, supporting **Brolti**, **Gzip** and **Tarballs**\n\n## Install\n\n```shell\nnpm install lambdafs --save-prod\n```\n\n## CLI\n\nThis package provides a [`brotli` CLI command](/bin) to conveniently compress files and/or folders.\n\n```shell\nnpx lambdafs /path/to/compress\n```\n\nThe resulting file will be a (potentially tarballed) Brotli compressed file, with the same base name as the source.\n\n\u003e Due to the highest compression level, it might take a while to compress large files (100MB ~ 5 minutes).\n\n## Usage\n\nThe `nodejs12.x` or `nodejs14.x` AWS Lambda runtime is required for this package to work properly.\n\n```javascript\nconst lambdafs = require('lambdafs');\n\nexports.handler = async (event, context) =\u003e {\n  try {\n    let file = __filename; // /var/task/index.js\n    let folder = __dirname; // /var/task\n\n    // Compressing\n    let compressed = {\n      file: await lambdafs.deflate(file), // /tmp/index.js.gz\n      folder: await lambdafs.deflate(folder), // /tmp/task.tar.gz\n    };\n\n    // Decompressing\n    let decompressed = {\n      file: await lambdafs.inflate(compressed.file), // /tmp/index.js\n      folder: await lambdafs.inflate(compressed.folder), // /tmp/task\n    };\n\n    return context.succeed({ file, folder, compressed, decompressed });\n  } catch (error) {\n    return context.fail(error);\n  }\n};\n```\n\n## API\n\n### `deflate(path: string): Promise\u003cstring\u003e`\n\nCompresses a file/folder with Gzip and returns the path to the compressed (tarballed) file.\n\n\u003e The resulting file will be saved under the default temporary directory (`/tmp` on AWS Lambda).\n\nDue to costly execution time on AWS Lambda, Gzip is *always* used to compress files.\n\n### `inflate(path: string): Promise\u003cstring\u003e`\n\nDecompresses a (tarballed) Brotli or Gzip compressed file and returns the path to the decompressed file/folder.\n\n\u003e The resulting file(s) will be saved under the default temporary directory (`/tmp` on AWS Lambda).\n\nSupported extensions are: `.br`, `.gz`, `.tar`, `.tar.br` (and `.tbr`), `.tar.gz` (and `.tgz`).\n\n\u003e For tarballs, original file modes are perserved. For any other files `0700` is assumed.\n\n## Rationale\n\nGetting large resources onto AWS Lambda can be a challenging task due to the [deployment package size limit](https://docs.aws.amazon.com/lambda/latest/dg/limits.html#w291aac11c35c15):\n\n| Limit  | Context                     |\n| ------ | --------------------------- |\n| 50 MB  | Zipped, for direct uploads. |\n| 250 MB | Unzipped, S3 and layers.    |\n\nFor this reason, it's important to achieve a very high compression ratio as well as fast decompression times.\n\nThis is where the [Brotli algorithm](https://www.opencpu.org/posts/brotli-benchmarks/) comes in:\n\n![Brotli Benchmarks](https://i.imgur.com/98UvYQL.png)\n\nIt allows us to get the best compression ratio and fast decompression times (at the expense of a slow compression).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falixaxel%2Flambdafs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falixaxel%2Flambdafs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falixaxel%2Flambdafs/lists"}