This is a utility that lets you decorate responses based on Arcjet decisions.
It currently supports experimental rate limit headers.
When should I use this?
You can use this package if you use the rate limit rule and want to set
experimental RateLimit-Policy and RateLimit headers.
See RateLimit header fields for HTTP on ietf.org for
more info.
Install
This package is ESM only.
Install with npm in Node.js:
npm install @arcjet/decorate
Example
import http from"node:http";
import { setRateLimitHeaders } from"@arcjet/decorate";
import arcjet, { shield } from"@arcjet/node";
// Get your Arcjet key at <https://app.arcjet.com>.// Set it as an environment variable instead of hard coding it.const arcjetKey = process.env.ARCJET_KEY;
if (!arcjetKey) {
thrownewError("Cannot find `ARCJET_KEY` environment variable");
}
const aj = arcjet({
key: arcjetKey,
rules: [
// Shield protects your app from common attacks.// Use `DRY_RUN` instead of `LIVE` to only log.shield({ mode: "LIVE" }),
],
});
const server = http.createServer(asyncfunction (
request: http.IncomingMessage,
response: http.ServerResponse,
) {
const decision = await aj.protect(request);
setRateLimitHeaders(response, decision);
if (decision.isDenied()) {
response.writeHead(403, { "Content-Type": "application/json" });
response.end(JSON.stringify({ message: "Forbidden" }));
return;
}
response.writeHead(200, { "Content-Type": "application/json" });
response.end(JSON.stringify({ message: "Hello world" }));
});
server.listen(8000);
Arcjet utilities for decorating responses with information
The npm package @arcjet/decorate receives a total of 1,526 weekly downloads. As such, @arcjet/decorate popularity was classified as popular.
We found that @arcjet/decorate demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Package last updated on 11 Nov 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.