@arcjet/node
Advanced tools
Comparing version 1.0.0-alpha.24 to 1.0.0-alpha.25
@@ -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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39805
145
+ Added@arcjet/analyze@1.0.0-alpha.25(transitive)
+ Added@arcjet/body@1.0.0-alpha.25(transitive)
+ Added@arcjet/duration@1.0.0-alpha.25(transitive)
+ Added@arcjet/env@1.0.0-alpha.25(transitive)
+ Added@arcjet/headers@1.0.0-alpha.25(transitive)
+ Added@arcjet/ip@1.0.0-alpha.25(transitive)
+ Added@arcjet/logger@1.0.0-alpha.25(transitive)
+ Added@arcjet/protocol@1.0.0-alpha.25(transitive)
+ Added@arcjet/runtime@1.0.0-alpha.25(transitive)
+ Added@arcjet/sprintf@1.0.0-alpha.25(transitive)
+ Added@arcjet/transport@1.0.0-alpha.25(transitive)
+ Addedarcjet@1.0.0-alpha.25(transitive)
- Removed@arcjet/analyze@1.0.0-alpha.24(transitive)
- Removed@arcjet/body@1.0.0-alpha.24(transitive)
- Removed@arcjet/duration@1.0.0-alpha.24(transitive)
- Removed@arcjet/env@1.0.0-alpha.24(transitive)
- Removed@arcjet/headers@1.0.0-alpha.24(transitive)
- Removed@arcjet/ip@1.0.0-alpha.24(transitive)
- Removed@arcjet/logger@1.0.0-alpha.24(transitive)
- Removed@arcjet/protocol@1.0.0-alpha.24(transitive)
- Removed@arcjet/runtime@1.0.0-alpha.24(transitive)
- Removed@arcjet/sprintf@1.0.0-alpha.24(transitive)
- Removed@arcjet/transport@1.0.0-alpha.24(transitive)
- Removedarcjet@1.0.0-alpha.24(transitive)
Updated@arcjet/body@1.0.0-alpha.25
Updated@arcjet/env@1.0.0-alpha.25
Updated@arcjet/ip@1.0.0-alpha.25
Updatedarcjet@1.0.0-alpha.25