Skip to content

Commit

Permalink
docs(examples): Additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton committed Feb 10, 2024
1 parent 8bfa978 commit 9476b08
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 91 deletions.
8 changes: 5 additions & 3 deletions examples/nextjs-13-pages-wrap/pages/api/arcjet-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const aj = arcjet({
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY,
rules: [
// Fixed window rate limit. Arcjet also supports sliding window and token
// bucket.
fixedWindow({
mode: "LIVE",
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m",
max: 1,
window: "1m", // 1 min fixed window
max: 1, // allow a single request (for demo purposes)
}),
],
});
Expand Down
8 changes: 5 additions & 3 deletions examples/nextjs-13-pages-wrap/pages/api/arcjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const aj = arcjet({
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY,
rules: [
// Fixed window rate limit. Arcjet also supports sliding window and token
// bucket.
fixedWindow({
mode: "LIVE",
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m",
max: 1,
window: "1m", // 1 min fixed window
max: 1, // allow a single request (for demo purposes)
}),
],
});
Expand Down
11 changes: 7 additions & 4 deletions examples/nextjs-14-app-dir-rl/app/api/arcjet/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ const aj = arcjet({
// See: https://nextjs.org/docs/app/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY!,
rules: [
// Fixed window rate limit. Arcjet also supports sliding window and token
// bucket.
fixedWindow({
mode: "LIVE",
characteristics: ["ip.src"],
window: "1h",
max: 1,
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m", // 1 min fixed window
max: 1, // allow a single request (for demo purposes)
}),
],
});
Expand Down
4 changes: 2 additions & 2 deletions examples/nextjs-14-app-dir-rl/app/api/custom_timeout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const aj = arcjet({
key: process.env.ARCJET_KEY!,
rules: [
validateEmail({
mode: "LIVE",
block: ["NO_MX_RECORDS"],
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
block: ["NO_MX_RECORDS"], // block email addresses with no MX records
}),
],
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const aj = arcjet({
key: process.env.ARCJET_KEY,
rules: [
validateEmail({
mode: "LIVE",
block: ["NO_MX_RECORDS"],
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
block: ["NO_MX_RECORDS"], // block email addresses with no MX records
}),
],
});
Expand Down
1 change: 1 addition & 0 deletions examples/nextjs-14-pages-wrap/.env.local.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ARCJET_KEY=
6 changes: 1 addition & 5 deletions examples/nextjs-14-pages-wrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ Route](https://nextjs.org/docs/pages/building-your-application/routing/api-route
npm ci
```

3. Add your Arcjet key to `.env.local`

```env
ARCJET_KEY=
```
3. Rename `.env.local.example` to `.env.local` and add your Arcjet key.

4. Start the dev server.

Expand Down
5 changes: 5 additions & 0 deletions examples/nextjs-14-pages-wrap/environment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace NodeJS {
export interface ProcessEnv {
readonly ARCJET_KEY: string;
}
}
110 changes: 46 additions & 64 deletions examples/nextjs-14-pages-wrap/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/nextjs-14-pages-wrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"@arcjet/next": "file:../../arcjet-next",
"next": "14.0.4",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18"
},
Expand All @@ -25,4 +25,4 @@
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}
}
8 changes: 5 additions & 3 deletions examples/nextjs-14-pages-wrap/pages/api/arcjet-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ const aj = arcjet({
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY!,
rules: [
// Fixed window rate limit. Arcjet also supports sliding window and token
// bucket.
fixedWindow({
mode: "LIVE",
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m",
max: 1,
window: "1m", // 1 min fixed window
max: 1, // allow a single request (for demo purposes)
}),
],
});
Expand Down
8 changes: 5 additions & 3 deletions examples/nextjs-14-pages-wrap/pages/api/arcjet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const aj = arcjet({
// See: https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables
key: process.env.ARCJET_KEY!,
rules: [
// Fixed window rate limit. Arcjet also supports sliding window and token
// bucket.
fixedWindow({
mode: "LIVE",
mode: "LIVE", // will block requests. Use "DRY_RUN" to log only
// Limiting by ip.src is the default if not specified
//characteristics: ["ip.src"],
window: "1m",
max: 1,
window: "1m", // 1 min fixed window
max: 1, // allow a single request (for demo purposes)
}),
],
});
Expand Down

0 comments on commit 9476b08

Please sign in to comment.