@arcjet/decorate 1.3.0 → 1.3.1

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 +47 -1
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ <!-- trunk-ignore-all(markdownlint/MD024) -->
2
+ <!-- trunk-ignore-all(markdownlint/MD001) -->
3
+
1
4
  <a href="https://arcjet.com" target="_arcjet-home">
2
5
  <picture>
3
6
  <source media="(prefers-color-scheme: dark)" srcset="https://arcjet.com/logo/arcjet-dark-lockup-voyage-horizontal.svg">
@@ -42,7 +45,7 @@ Install with npm in Node.js:
42
45
  npm install @arcjet/decorate
43
46
  ```
44
47
 
45
- ## Example
48
+ ## Use
46
49
 
47
50
  ```ts
48
51
  import http from "node:http";
@@ -87,10 +90,53 @@ const server = http.createServer(async function (
87
90
  server.listen(8000);
88
91
  ```
89
92
 
93
+ ## API
94
+
95
+ This package exports the identifier
96
+ [`setRateLimitHeaders`][api-set-rate-limit-headers].
97
+ There is no default export.
98
+
99
+ This package exports the [TypeScript][] type
100
+ [`ArcjetCanDecorate`][api-arcjet-can-decorate].
101
+
102
+ ### `ArcjetCanDecorate`
103
+
104
+ This type represents a value that you can decorate with rate limit headers.
105
+ It can be anything that looks like `Headers` (Fetch),
106
+ `OutgoingMessage` (Node.js), or `Response` (Fetch).
107
+
108
+ ###### Type
109
+
110
+ ```ts
111
+ type ArcjetCanDecorate = HeaderLike | OutgoingMessageLike | ResponseLike;
112
+ ```
113
+
114
+ ### `setRateLimitHeaders(value, decision)`
115
+
116
+ Decorates a response with rate limit headers based on an Arcjet decision.
117
+ It sets `RateLimit-Policy` and `RateLimit` headers that conform to the
118
+ [Rate Limit fields for
119
+ HTTP](https://ietf-wg-httpapi.github.io/ratelimit-headers/draft-ietf-httpapi-ratelimit-headers.html)
120
+ draft specification.
121
+
122
+ ###### Parameters
123
+
124
+ - `value` ([`ArcjetCanDecorate`][api-arcjet-can-decorate])
125
+ — the response or headers object to decorate
126
+ - `decision` (`ArcjetDecision`)
127
+ — the decision returned from `protect()`
128
+
129
+ ###### Returns
130
+
131
+ Nothing (`undefined`).
132
+
90
133
  ## License
91
134
 
92
135
  [Apache License, Version 2.0][apache-license] © [Arcjet Labs, Inc.][arcjet]
93
136
 
94
137
  [arcjet]: https://arcjet.com
95
138
  [apache-license]: http://www.apache.org/licenses/LICENSE-2.0
139
+ [api-arcjet-can-decorate]: #arcjetcandecorate
140
+ [api-set-rate-limit-headers]: #setratelimitheadersvalue-decision
96
141
  [ietf-rate-limit]: https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers-08
142
+ [typescript]: https://www.typescriptlang.org/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/decorate",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Arcjet utilities for decorating responses with information",
5
5
  "keywords": [
6
6
  "arcjet",
@@ -42,15 +42,15 @@
42
42
  "test": "npm run build && npm run lint && npm run test-coverage"
43
43
  },
44
44
  "dependencies": {
45
- "@arcjet/protocol": "1.3.0",
46
- "@arcjet/sprintf": "1.3.0"
45
+ "@arcjet/protocol": "1.3.1",
46
+ "@arcjet/sprintf": "1.3.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@arcjet/eslint-config": "1.3.0",
50
- "@arcjet/rollup-config": "1.3.0",
51
- "@rollup/wasm-node": "4.57.1",
49
+ "@arcjet/eslint-config": "1.3.1",
50
+ "@arcjet/rollup-config": "1.3.1",
51
+ "@rollup/wasm-node": "4.59.0",
52
52
  "@types/node": "24.11.0",
53
- "eslint": "9.39.2",
53
+ "eslint": "9.39.3",
54
54
  "typescript": "5.9.3"
55
55
  },
56
56
  "publishConfig": {