Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add bugs and author info & update readme #254

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- semgrep@1.61.1
- semgrep@1.62.0
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- trufflehog@3.67.6
- trufflehog@3.68.0
disabled:
# tfsec and checkov are replaced by Trivy
- tfsec
Expand Down
10 changes: 6 additions & 4 deletions analyze/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/analyze`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fanalyze?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fanalyze?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/analyze">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fanalyze?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fanalyze?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] helps developers protect their apps in just a few lines of
Expand Down
9 changes: 9 additions & 0 deletions analyze/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "analyze"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
68 changes: 62 additions & 6 deletions arcjet-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/next`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fnext?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fnext?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/next">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fnext?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fnext?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] helps developers protect their apps in just a few lines of
Expand All @@ -31,7 +33,61 @@ started.
npm install -S @arcjet/next
```

## Example
## Rate limit example

The [Arcjet rate
limit](https://docs.arcjet.com/rate-limiting/concepts) 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.

See the [Arcjet rate limit
documentation](https://docs.arcjet.com/rate-limiting/quick-start/nextjs) for
details.

```ts
import arcjet, { tokenBucket } from "@arcjet/next";
import { NextResponse } from "next/server";

const aj = arcjet({
key: process.env.ARCJET_KEY!, // Get your site key from https://app.arcjet.com
rules: [
// Create a token bucket rate limit. Other algorithms are supported.
tokenBucket({
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
interval: 10, // refill every 10 seconds
capacity: 10, // bucket maximum capacity of 10 tokens
}),
],
});

export async function GET(req: Request) {
const userId = "user123"; // Replace with your authenticated user ID
const decision = await aj.protect(req, { userId, requested: 5 }); // Deduct 5 tokens from the bucket
console.log("Arcjet decision", decision);

if (decision.isDenied()) {
return NextResponse.json(
{ error: "Too Many Requests", reason: decision.reason },
{ status: 429 },
);
}

return NextResponse.json({ message: "Hello world" });
}
```

## Shield example

[Arcjet Shield](https://docs.arcjet.com/shield/concepts) protects your
application against common attacks, including the OWASP Top 10. It’s enabled by
default and runs on every request with negligible performance impact.

See the [Arcjet Shield
documentation](https://docs.arcjet.com/shield/quick-start/nextjs) for details.

```ts
import arcjet from "@arcjet/next";
Expand All @@ -42,7 +98,7 @@ const aj = arcjet({
// and set it as an environment variable rather than hard coding.
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY,
rules: [],
rules: [], // Shield requires no rule configuration
});

export async function GET(req: Request) {
Expand Down
9 changes: 9 additions & 0 deletions arcjet-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "arcjet-next"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions arcjet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `arcjet`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/arcjet">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/arcjet?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] helps developers protect their apps in just a few lines of
Expand Down
9 changes: 9 additions & 0 deletions arcjet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "arcjet"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions duration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/ip`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/duration">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fduration?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fduration?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] utilities for parsing duration strings.
Expand Down
9 changes: 9 additions & 0 deletions duration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "ip"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/eslint-config`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Feslint-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Feslint-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/eslint-config">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Feslint-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Feslint-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

Custom eslint config for [Arcjet][arcjet] projects.
Expand Down
9 changes: 9 additions & 0 deletions eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "eslint-config"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions ip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/ip`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/ip">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fip?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] utilities for finding the originating IP of a request.
Expand Down
9 changes: 9 additions & 0 deletions ip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "ip"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/logger`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Flogger?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Flogger?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/logger">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Flogger?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Flogger?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

[Arcjet][arcjet] logging interface which mirrors the `console` interface but
Expand Down
9 changes: 9 additions & 0 deletions logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "logger"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions protocol/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/protocol`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fprotocol?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fprotocol?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/protocol">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Fprotocol?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Fprotocol?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

The TypeScript & JavaScript interface into the [Arcjet][arcjet] protocol.
Expand Down
9 changes: 9 additions & 0 deletions protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "protocol"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
10 changes: 6 additions & 4 deletions rollup-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# `@arcjet/rollup-config`

<p>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Frollup-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Frollup-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
<a href="https://www.npmjs.com/package/@arcjet/rollup-config">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/npm/v/%40arcjet%2Frollup-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=000000&color=5C5866">
<img alt="npm badge" src="https://img.shields.io/npm/v/%40arcjet%2Frollup-config?style=flat-square&label=%E2%9C%A6Aj&labelColor=ECE6F0&color=ECE6F0">
</picture>
</a>
</p>

Custom rollup config for [Arcjet][arcjet] projects.
Expand Down
9 changes: 9 additions & 0 deletions rollup-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git+https://github.com/arcjet/arcjet-js.git",
"directory": "rollup-config"
},
"bugs": {
"url": "https://github.com/arcjet/arcjet-js/issues",
"email": "[email protected]"
},
"author": {
"name": "Arcjet",
"email": "[email protected]",
"url": "https://arcjet.com"
},
"engines": {
"node": ">=18"
},
Expand Down
Loading
Loading