Skip to content

Support compression for static files - #2003

Merged
tshemsedinov merged 7 commits into
metarhia:masterfrom
xxsanekxx:feature/support-compression-for-static
Apr 4, 2026
Merged

tshemsedinov merged 7 commits into
metarhia:masterfrom
xxsanekxx:feature/support-compression-for-static

Conversation

@xxsanekxx

@xxsanekxx xxsanekxx commented Jan 10, 2026

Copy link
Copy Markdown
Contributor

Added support for compression for static files (gzip, deflate, br, zstd)
To use compression, we need to pass the compression type into the options:
new Static('lib', application, { compressType: 'br', });
issue: #2002

In metacom it's enough to refactor transport (http)

  • tests and linter show no problems (npm t)
  • tests are added/updated for bug fixes and new features
  • code is properly formatted (npm run fix)
  • description of changes is added in CHANGELOG.md
  • update .d.ts typings

@xxsanekxx

Copy link
Copy Markdown
Contributor Author

if we don't want to use node:stream/consumer we can refactor compress to for await of

async compress(filePath) {
    const compressor = getCompressorStream(this.compressType);
    if (!compressor) {
      throw new Error(`Unsupported compression type: ${this.compressType}`);
    }
    const fileStream = node.fs.createReadStream(filePath);
    fileStream.pipe(compressor);

    const chunks = [];
    for await (const chunk of compressor) {
      chunks.push(chunk);
    }
    return Buffer.concat(chunks);
  }

Comment thread lib/static.js Outdated
@xxsanekxx
xxsanekxx force-pushed the feature/support-compression-for-static branch from c58be88 to c3aae14 Compare January 14, 2026 18:45
Comment thread lib/static.js Outdated
Comment thread lib/static.js Outdated
Comment thread lib/static.js Outdated
Comment thread package.json Outdated
@xxsanekxx
xxsanekxx force-pushed the feature/support-compression-for-static branch 2 times, most recently from 0a6e053 to 2178d39 Compare February 10, 2026 06:27
@tshemsedinov tshemsedinov changed the title feat: added support compression for static files, Ref #2002 Support compression for static files Feb 10, 2026
Comment thread lib/static.js Outdated
Comment thread lib/static.js Outdated
@xxsanekxx
xxsanekxx force-pushed the feature/support-compression-for-static branch from 2178d39 to f90ce00 Compare February 11, 2026 17:22

@tshemsedinov tshemsedinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need tests with real http requests to ensure client side will understand decoding method

Comment thread lib/static.js Outdated
@tshemsedinov

Copy link
Copy Markdown
Member

Looks like ready to land after landing metacom PR metarhia/metacom#527 and adding tests

Comment thread test/static.js Outdated

@tshemsedinov tshemsedinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix tests for older node versions

@xxsanekxx
xxsanekxx requested a review from tshemsedinov March 25, 2026 17:23
Comment thread lib/static.js Outdated
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
Comment thread lib/static.js
Co-authored-by: Timur Shemsedinov <timur.shemsedinov@gmail.com>
@tshemsedinov
tshemsedinov merged commit f831c21 into metarhia:master Apr 4, 2026
13 checks passed
@tshemsedinov

Copy link
Copy Markdown
Member

Fixed bug here: c66f150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants