@remix-run/compression-middleware 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -18
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,20 +1,25 @@
1
1
  # compression-middleware
2
2
 
3
- Middleware for compressing HTTP responses for use with [`@remix-run/fetch-router`](https://github.com/remix-run/remix/tree/main/packages/fetch-router).
3
+ Response compression middleware for Remix. It negotiates `br`, `gzip`, and `deflate` from `Accept-Encoding` and applies sensible defaults for when compression is useful.
4
4
 
5
- Automatically compresses responses using `gzip`, `brotli`, or `deflate` based on the client's `Accept-Encoding` header, with intelligent defaults for media type filtering and threshold-based compression.
5
+ ## Features
6
+
7
+ - **Encoding Negotiation** - Selects the best supported encoding from `Accept-Encoding`
8
+ - **Compression Guards** - Skips already-compressed responses and range-enabled responses
9
+ - **Size Thresholds** - Configurable minimum response size for compression
10
+ - **MIME Filtering** - Compresses only content types likely to benefit
6
11
 
7
12
  ## Installation
8
13
 
9
14
  ```sh
10
- npm install @remix-run/compression-middleware
15
+ npm i remix
11
16
  ```
12
17
 
13
18
  ## Usage
14
19
 
15
20
  ```ts
16
- import { createRouter } from '@remix-run/fetch-router'
17
- import { compression } from '@remix-run/compression-middleware'
21
+ import { createRouter } from 'remix/fetch-router'
22
+ import { compression } from 'remix/compression-middleware'
18
23
 
19
24
  let router = createRouter({
20
25
  middleware: [compression()],
@@ -35,8 +40,8 @@ The middleware will automatically compress responses for compressible MIME types
35
40
  Set the minimum response size in bytes to compress:
36
41
 
37
42
  ```ts
38
- import { createRouter } from '@remix-run/fetch-router'
39
- import { compression } from '@remix-run/compression-middleware'
43
+ import { createRouter } from 'remix/fetch-router'
44
+ import { compression } from 'remix/compression-middleware'
40
45
 
41
46
  let router = createRouter({
42
47
  middleware: [
@@ -54,8 +59,8 @@ let router = createRouter({
54
59
  Customize which compression algorithms to support:
55
60
 
56
61
  ```ts
57
- import { createRouter } from '@remix-run/fetch-router'
58
- import { compression } from '@remix-run/compression-middleware'
62
+ import { createRouter } from 'remix/fetch-router'
63
+ import { compression } from 'remix/compression-middleware'
59
64
 
60
65
  let router = createRouter({
61
66
  middleware: [
@@ -69,8 +74,8 @@ let router = createRouter({
69
74
  The `encodings` option can also be a function that receives the response:
70
75
 
71
76
  ```ts
72
- import { createRouter } from '@remix-run/fetch-router'
73
- import { compression } from '@remix-run/compression-middleware'
77
+ import { createRouter } from 'remix/fetch-router'
78
+ import { compression } from 'remix/compression-middleware'
74
79
 
75
80
  let router = createRouter({
76
81
  middleware: [
@@ -94,9 +99,9 @@ let router = createRouter({
94
99
  You can customize this behavior with the `filterMediaType` option:
95
100
 
96
101
  ```ts
97
- import { createRouter } from '@remix-run/fetch-router'
98
- import { compression } from '@remix-run/compression-middleware'
99
- import { isCompressibleMimeType } from '@remix-run/mime'
102
+ import { createRouter } from 'remix/fetch-router'
103
+ import { compression } from 'remix/compression-middleware'
104
+ import { isCompressibleMimeType } from 'remix/mime'
100
105
 
101
106
  let router = createRouter({
102
107
  middleware: [
@@ -117,8 +122,8 @@ let router = createRouter({
117
122
  You can pass options options to the underlying Node.js `zlib` and `brotli` compressors for fine-grained control:
118
123
 
119
124
  ```ts
120
- import { createRouter } from '@remix-run/fetch-router'
121
- import { compression } from '@remix-run/compression-middleware'
125
+ import { createRouter } from 'remix/fetch-router'
126
+ import { compression } from 'remix/compression-middleware'
122
127
  import { zlib } from 'node:zlib'
123
128
 
124
129
  let router = createRouter({
@@ -141,8 +146,8 @@ Like `encodings`, both `zlib` and `brotli` options can also be functions that re
141
146
 
142
147
  ```ts
143
148
  import zlib from 'node:zlib'
144
- import { createRouter } from '@remix-run/fetch-router'
145
- import { compression } from '@remix-run/compression-middleware'
149
+ import { createRouter } from 'remix/fetch-router'
150
+ import { compression } from 'remix/compression-middleware'
146
151
 
147
152
  let router = createRouter({
148
153
  middleware: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/compression-middleware",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Middleware for compressing HTTP responses",
5
5
  "author": "Michael Jackson <mjijackson@gmail.com>",
6
6
  "license": "MIT",
@@ -28,14 +28,14 @@
28
28
  "devDependencies": {
29
29
  "@types/node": "^24.6.0",
30
30
  "@typescript/native-preview": "7.0.0-dev.20251125.1",
31
- "@remix-run/response": "0.3.1",
32
- "@remix-run/fetch-router": "0.15.1",
33
- "@remix-run/mime": "0.3.0"
31
+ "@remix-run/fetch-router": "0.17.0",
32
+ "@remix-run/response": "0.3.2",
33
+ "@remix-run/mime": "0.4.0"
34
34
  },
35
35
  "dependencies": {
36
- "@remix-run/fetch-router": "^0.15.1",
37
- "@remix-run/response": "^0.3.1",
38
- "@remix-run/mime": "^0.3.0"
36
+ "@remix-run/fetch-router": "^0.17.0",
37
+ "@remix-run/mime": "^0.4.0",
38
+ "@remix-run/response": "^0.3.2"
39
39
  },
40
40
  "keywords": [
41
41
  "fetch",