Socket
Socket
Sign inDemoInstall

@arcjet/node

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/node - npm Package Compare versions

Comparing version 1.0.0-alpha.24 to 1.0.0-alpha.25

2

index.js

@@ -35,3 +35,3 @@ import core__default from 'arcjet';

const sdkStack = "NODEJS";
const sdkVersion = "1.0.0-alpha.24";
const sdkVersion = "1.0.0-alpha.25";
return createClient({

@@ -38,0 +38,0 @@ transport,

{
"name": "@arcjet/node",
"version": "1.0.0-alpha.24",
"version": "1.0.0-alpha.25",
"description": "Arcjet SDK for Node.js",

@@ -43,15 +43,15 @@ "license": "Apache-2.0",

"dependencies": {
"@arcjet/env": "1.0.0-alpha.24",
"@arcjet/headers": "1.0.0-alpha.24",
"@arcjet/ip": "1.0.0-alpha.24",
"@arcjet/logger": "1.0.0-alpha.24",
"@arcjet/protocol": "1.0.0-alpha.24",
"@arcjet/transport": "1.0.0-alpha.24",
"@arcjet/body": "1.0.0-alpha.24",
"arcjet": "1.0.0-alpha.24"
"@arcjet/env": "1.0.0-alpha.25",
"@arcjet/headers": "1.0.0-alpha.25",
"@arcjet/ip": "1.0.0-alpha.25",
"@arcjet/logger": "1.0.0-alpha.25",
"@arcjet/protocol": "1.0.0-alpha.25",
"@arcjet/transport": "1.0.0-alpha.25",
"@arcjet/body": "1.0.0-alpha.25",
"arcjet": "1.0.0-alpha.25"
},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.24",
"@arcjet/rollup-config": "1.0.0-alpha.24",
"@arcjet/tsconfig": "1.0.0-alpha.24",
"@arcjet/eslint-config": "1.0.0-alpha.25",
"@arcjet/rollup-config": "1.0.0-alpha.25",
"@arcjet/tsconfig": "1.0.0-alpha.25",
"@jest/globals": "29.7.0",

@@ -61,3 +61,3 @@ "@types/node": "18.18.0",

"jest": "29.7.0",
"typescript": "5.5.4"
"typescript": "5.6.2"
},

@@ -64,0 +64,0 @@ "publishConfig": {

@@ -45,10 +45,11 @@ <a href="https://arcjet.com" target="_arcjet-home">

The [Arcjet rate limit][rate-limit-concepts-docs] example below applies a token
bucket rate limit rule to a route where we identify the user based on their ID
e.g. if they are logged in. The bucket is configured with a maximum capacity of
10 tokens and refills by 5 tokens every 10 seconds. Each request consumes 5
tokens.
The example below applies a token bucket rate limit rule to a route where we
identify the user based on their ID e.g. if they are logged in. The bucket is
configured with a maximum capacity of 10 tokens and refills by 5 tokens every 10
seconds. Each request consumes 5 tokens.
Bot detection is also enabled to block requests from known bots.
```ts
import arcjet, { tokenBucket } from "@arcjet/node";
import arcjet, { tokenBucket, detectBot } from "@arcjet/node";
import http from "node:http";

@@ -58,2 +59,3 @@

key: process.env.ARCJET_KEY!, // Get your site key from https://app.arcjet.com
characteristics: ["userId"], // track requests by a custom user ID
rules: [

@@ -63,3 +65,2 @@ // Create a token bucket rate limit. Other algorithms are supported.

mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
characteristics: ["userId"], // track requests by a custom user ID
refillRate: 5, // refill 5 tokens per interval

@@ -69,2 +70,8 @@ interval: 10, // refill every 10 seconds

}),
detectBot({
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// configured with a list of bots to allow from
// https://arcjet.com/bot-list
allow: [], // "allow none" will block all detected bots
}),
],

@@ -82,6 +89,4 @@ });

if (decision.isDenied()) {
res.writeHead(429, { "Content-Type": "application/json" });
res.end(
JSON.stringify({ error: "Too Many Requests", reason: decision.reason }),
);
res.writeHead(403, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "Forbidden" }));
} else {

@@ -143,4 +148,3 @@ res.writeHead(200, { "Content-Type": "application/json" });

[example-source]: https://github.com/arcjet/arcjet-js-example
[rate-limit-concepts-docs]: https://docs.arcjet.com/rate-limiting/concepts
[shield-concepts-docs]: https://docs.arcjet.com/shield/concepts
[apache-license]: http://www.apache.org/licenses/LICENSE-2.0
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc